refactor, split out data extraction