diff --git a/hpvm/include/SupportVISC/DFG2LLVM.h b/hpvm/include/SupportVISC/DFG2LLVM.h
index c3db1a77c1aa509c26e8d119b0b8e69b6df910a6..a2d17801ff2a61cded3822475c6f6c44c0821d9a 100644
--- a/hpvm/include/SupportVISC/DFG2LLVM.h
+++ b/hpvm/include/SupportVISC/DFG2LLVM.h
@@ -341,6 +341,8 @@ Function *CodeGenTraversal::addArgument(Function* F, Type* Ty, const Twine& name
       ai != ae; ++ai) {
     ArgTypes.push_back(ai->getType());
   }
+  ArgTypes.push_back(new_arg->getType());
+  
   // Adding new arguments to the function argument list, would not change the
   // function type. We need to change the type of this function to reflect the
   // added arguments. So, we create a clone of this function with the correct
@@ -377,8 +379,9 @@ Function *CodeGenTraversal::addIdxDimArgs(Function* F) {
   Function *newF;
   for (int i = 0; i < 6; ++i) {
     newF = addArgument(F, Type::getInt64Ty(F->getContext()), names[i]);
+    ArgTypes.push_back(new_arg->getType());
     F->replaceAllUsesWith(UndefValue::get(F->getType()));
-    F->eraseFromParent();
+   // F->eraseFromParent();
     F = newF;
   }
   errs() << "Function Type after adding args: " << *newF->getFunctionType() << "\n";