created main loop