refactored reductions to improve correctness