fixed order in main loop