used map method to calculate sum and average values