reduction algorithm implemented