move actions to end of main loop