Changed the condition of while loop