create the main loop