fix some chi2 bug