refactoring save bat