fix bugs in handling errors involving unbalanced parens, undefined variables