switch to for loops instead of while

makes the size on card a bit smaller