fix bug causing total_frames to be doubled