Added Chi values to code, corrected various syntax errors