median, min, max functions implemented