updated Kappa to avoid integer overflow