file management refactoring