create main loop