Added aggregate function collect and code to merge aggregated data set together.