main loop changed