set the main loop