Updating the code to control the frame rate of the game