Adding reduction algorithm