Fixing aggregation logic