move median and average to array extension