average function added