Modified idle function to enforce frame rate