changes to main loop