added while loop in main