Final reduction algorithm added