update main loop