See #16: reduce function