added an error check and a more verbose error message to the parser.