updated aggregation algo