Fixed the while loop to cycle less