while loop fixed