Creating global-level aggregate function