file/input refactoring