upgrade average method from for loop to built-in sum method