Fix the aggregate function.