This is another case where it might help a small amount to do this in the while loop so as to avoid so many function calls. I don't think this by any means would be detrimental, but its performance impact might at least be measurable. Although I certainly appreciate the desire to keep this logic separate.