refactoring: remove global variable from function
refactor parser