Clean up and better while loop