Totally fixed infinite while loop