Separated reduce function to help with readability