while loop doesn't work