refactor of error messages in parser