added aggregation calculation