Fixed the game loop