xml file save and refactoring