refactor fileio