some refactoring of the parser code