fixed bug in aggregation