fix bug with game loop