refactor for new datafile format