Refactor parser functions