median function added.