Replacing an each with reduce

The functionality has not changed, but the code is more elegant by
using `reduce` instead of `each`.

This way no accumulator is declared, no explicit return is
needed.