add range limit to n to handle less than 0 and greater than numFrames