Refactor parsing