improvements on main game loop