parser code refactoring