refactor IO operations and simplify methods