file input refactoring