Added main loop to Main()