Implemented aggregation pipeline.