Created getAvrg function