added comments to main reduce frame function