refine game loop