added reduce.m