updated to use mp_median