added timer func to control FPS