finished main loop