refactor to FlatFile