Fix error in calling chi2 function