create main loop.