main loop updated