diff --git a/ComputingTasks.cc b/ComputingTasks.cc
index c4dc0778b05cd9c7d847102c848dddd7e24829d7..ebfdb3663996850a9e52b7660e0e838d59b2469e 100644
--- a/ComputingTasks.cc
+++ b/ComputingTasks.cc
@@ -1982,6 +1982,36 @@ ConditionalForecastStatement::ConditionalForecastStatement(const OptionsList &op
 {
 }
 
+Statement *
+ConditionalForecastStatement::cloneAndReindexSymbIds(DataTree &dynamic_datatree, SymbolTable &orig_symbol_table)
+{
+  OptionsList new_options_list = options_list;
+  try
+    {
+      OptionsList::symbol_list_options_t::const_iterator it =
+        options_list.symbol_list_options.find("controlled_varexo");
+      if (it != options_list.symbol_list_options.end())
+        {
+          SymbolList new_options_symbol_list;
+          SymbolTable *new_symbol_table =  dynamic_datatree.getSymbolTable();
+          vector<string> symbols = it->second.get_symbols();
+          for (vector<string>::const_iterator it1 = symbols.begin(); it1 != symbols.end(); it1++)
+            {
+              new_symbol_table->getID(*it1);
+              new_options_symbol_list.addSymbol(*it1);
+            }
+          new_options_list.symbol_list_options["controlled_varexo"] = new_options_symbol_list;
+        }
+    }
+  catch (SymbolTable::UnknownSymbolNameException &e)
+    {
+      cerr << "ERROR: A variable in the conditional_forecast statement was not found in the symbol table" << endl
+           << "       This likely means that you have declared a varexo that is not used in the model" << endl;
+      exit(EXIT_FAILURE);
+    }
+  return new ConditionalForecastStatement(new_options_list);
+}
+
 void
 ConditionalForecastStatement::writeOutput(ostream &output, const string &basename) const
 {
diff --git a/ComputingTasks.hh b/ComputingTasks.hh
index 03b1f4cec3633613237b69a8a46e36771c3bc1c2..72c3649fefc2a2e88bd2f2646ea6c8757df0dbf0 100644
--- a/ComputingTasks.hh
+++ b/ComputingTasks.hh
@@ -554,6 +554,7 @@ private:
 public:
   ConditionalForecastStatement(const OptionsList &options_list_arg);
   virtual void writeOutput(ostream &output, const string &basename) const;
+  virtual Statement *cloneAndReindexSymbIds(DataTree &dynamic_datatree, SymbolTable &orig_symbol_table);
 };
 
 class PlotConditionalForecastStatement : public Statement