refactored FileIo