Index: /issm/trunk/src/c/objects/Elements/Penta.cpp
===================================================================
--- /issm/trunk/src/c/objects/Elements/Penta.cpp	(revision 4342)
+++ /issm/trunk/src/c/objects/Elements/Penta.cpp	(revision 4343)
@@ -4232,8 +4232,4 @@
 	Input* original_input=NULL;
 
-	/*Extrude the original input: */
-	original_input=(Input*)this->inputs->GetInput(enum_type);
-	original_input->Extrude();
-
 	/*recover parameters: */
 	inputs->GetParameterValue(&onbed,ElementOnBedEnum);
@@ -4243,25 +4239,29 @@
 	if(onbed==1 & onsurface==0){
 
-		/*this element is on the bed. We are going to, follow the upper element until we reach the surface. At each upper element, 
-		 * we'll add the input of the lower element*/
-
-		penta=this;
+		/*OK, we are on bed. we will follow the steps:
+		 * 1: find input and extrude it.
+		 * 2: follow the upper element until we reach the surface
+		 * 3: for each element, we will add a copy of the extruded input*/
+
+		/*Step1: Extrude the original input: */
 		original_input=(Input*)this->inputs->GetInput(enum_type);
 		if(!original_input) ISSMERROR("%s%s"," could not find input with enum:",EnumAsString(enum_type));
-
+		original_input->Extrude();
+
+		/*Step 2: this input has been extruded for this element, now follow the upper element*/
+		penta=this;
 		for(;;){
 
 			/* get upper Penta*/
 			penta=penta->GetUpperElement();
-
-			/*Add input of the basal element*/
+			ISSMASSERT(penta->Id()!=this->id);
+
+			/*Add input of the basal element to penta->inputs*/
 			Input* copy=NULL;
 			copy=(Input*)original_input->copy();
-			inputs->AddObject((Input*)copy);
-
+			penta->inputs->AddInput((Input*)copy);
 
 			/*Stop if we have reached the surface*/
 			if (penta->IsOnSurface()) break;
-			ISSMASSERT(penta->Id()!=this->id);
 
 		}
