changed medianValue Method so that its right