better error handling during parsing