more work on main loop