Tried to fix the while loop