autosave refactoring