This question is asking for a review of a code rewrite.
I feel like the code snippet above "My Review" is irrelevant and potentially distracting. However, the user has included it because, as part of his question, he's asking whether or not his rewrite produces the same end-results as the original code.
My answer focuses just on the rewritten part of the code and only makes points that are relevant whether or not the original version of the code is provided.
I feel like the question he seems most interested in having answered (and the question he posed as a comment to my answer) is off-topic for CodeReview.
Part of being on-topic for CodeReview means that your code is working to the best of your knowledge.
I'm going to argue that if you're asking for a review of Code Snippet B which is a rewrite of Code Snippet A, and as part of your question, you're asking if Code Snippet B produces the same results as Code Snippet A, then your question doesn't get to count as working to the best of your knowledge. It may have no known flaws as far as your concerned, but in this case, it can only be because you haven't put forth a minimum testing effort.
It's okay if your posted code snippet has flaws. The criteria only states that it works as intended to the best of your knowledge. To the best of my knowledge, every line of untested code I've ever written worked as intended. There has to be some minimum level of testing expected.
With this specific question, I think perhaps simply editing out the original code snippet might suffice for making this question fine.