implemented aggregation logic