Added aggregation code