Refactoring IO