changed avg function when enlarging