Added cohorts logic to median functions