Refactor parser