IO refactoring