diff --git a/src/SubModel.cc b/src/SubModel.cc
index 1dd859cfd0d145ba6855bed5c58fd7bba57e0b27..2081735019c6f4b5d1d0d5e9e5e54f46bf38d557 100644
--- a/src/SubModel.cc
+++ b/src/SubModel.cc
@@ -1227,15 +1227,18 @@ PacModelTable::transformPass(const lag_equivalence_table_t &unary_ops_nodes,
 
           // Associate the coefficients of the linear combination with the right components
           for (auto [var, coeff] : terms)
-            if (auto it = find_if(components.begin(), components.end(),
-                                  [&](const auto &v) { return get<0>(v) == dynamic_model.AddVariable(var); });
-                it != components.end())
-              get<4>(*it) = coeff;
-            else
-              {
-                cerr << "ERROR: the model equation defining the 'target' of 'pac_target_info(" << name << ")' contains a variable (" << symbol_table.getName(var) << ") that is not declared as a 'component'" << endl;
-                exit(EXIT_FAILURE);
-              }
+	    {
+	      auto var1 = var;
+	      if (auto it = find_if(components.begin(), components.end(),
+				    [&](const auto &v) { return get<0>(v) == dynamic_model.AddVariable(var1); });
+		  it != components.end())
+		get<4>(*it) = coeff;
+	      else
+		{
+		  cerr << "ERROR: the model equation defining the 'target' of 'pac_target_info(" << name << ")' contains a variable (" << symbol_table.getName(var1) << ") that is not declared as a 'component'" << endl;
+		  exit(EXIT_FAILURE);
+		}
+	    }
 
           // Verify that all declared components appear in that equation
           for (const auto &[component, growth_component, auxname, kind, coeff, growth_neutrality_param, h_indices, original_growth_component, growth_component_info] : components)