Added .upto iterator instead of a while loop.