refactored code and added average, min, max, count aggregation methods
resolved merge conflicts