Better while loop in main