added the main loop