refactor Gameloop