Updated aggregate function.