Fixed variable names in reduce.