Add average function, to calculate the average of values