Fixed while loop