refactoring file system code