refactor parsing to use a record