updated all reduction code