do the reduce in code