 				list[0] = value;
 				value = list;
 			}
-			if(elements is XMLList)
+			if(value is XMLList)
 			{
 				// remove all existing elements
 				var chldrn:XMLList = this.child(elementName);

				len = chldrn.length() -1;
				for (i= len; i >= 0;  i--)
				{
					// remove the nodes
					// remove the children
					// adjust the childIndexes
				}
				var curChild = _children[childIdx];
				// Now add them in.
				for each(chld in elements)
				{
				
					if(!curChild)
					{
						curChild = appendChild(chld);

				len = chldrn.length() -1;
				for (i= len; i >= 0;  i--)
				{
					removeChild(chldrn[i]);
					// remove the nodes
					// remove the children
					// adjust the childIndexes
				}
				var curChild = _children[childIdx];
				// Now add them in.
				len = value.length();
				for(i=0;i<len;i++)
				{
					child = value[i];
					if(!curChild)
					{
						curChild = appendChild(chld);
