refactoring IO