refactor parser code