Improved the save xml method