Added a median function.