Wrote function for mean.