new calculation of mean and median