added pre-aggregation step