Bug using while loop instead

check this out and see if this is good