Wrap redundant reduce and reduceRight code in helper