remade the game loop