fix error in computing total_frames