Fixed the median finding.