diff --git a/lib/xmlbuilder.js b/lib/xmlbuilder.js
index <HASH>..<HASH> 100644
--- a/lib/xmlbuilder.js
+++ b/lib/xmlbuilder.js
@@ -12,13 +12,13 @@ XMLFragment.prototype.importXMLBuilder = function(xmlbuilder) {
 };
 
 XMLFragment.prototype.clone = function(deep) {
-  var fragment = new XMLFragment(this.parent, this.name, this.attributes, this.value);
+  var clonedSelf = new XMLFragment(this.parent, this.name, this.attributes, this.value);
   if (deep) {
     this.children.forEach(function(child) {
       var clonedChild = child.clone(deep);
       clonedChild.parent = fragment;
-      fragment.children.push(clonedChild);
+      clonedSelf.children.push(clonedChild);
     }, this);
   }
-  return this;
+  return clonedSelf;
 };
Return cloned instance correctly