refactor confidence intervals; tests