"while" is much cleaner than "for", in this case