edited game loop