created getBestMediumTime function