fix return types for aggregation functions