while loop incorrect