better logic for quantiles