Changed the while loop condition