Add function for calculating the median.