use one variable for number of frames to read in each iteration