Refactoring the aggregation method into a new module