another attempt at fixing gameloop