i/o refactoring