Fixed the while loop

Fixed the while loop