fixing logic error for exception handling in parser