refactor parsing