Fixed while loop stuff