Fix aggregation function in conditions