Median function added