diff --git a/src/ModelTree.cc b/src/ModelTree.cc
index 440236eb9531f438003e81692497f140960bfb7b..609c3c63e155d32861c732654a11cb54db6a6819 100644
--- a/src/ModelTree.cc
+++ b/src/ModelTree.cc
@@ -1965,29 +1965,23 @@ ModelTree::addAuxEquation(expr_t eq)
 }
 
 void
-ModelTree::addTrendVariables(vector<int> trend_vars, expr_t growth_factor) noexcept(false)
+ModelTree::addTrendVariables(const vector<int> &trend_vars, expr_t growth_factor) noexcept(false)
 {
-  while (!trend_vars.empty())
-    if (trend_symbols_map.find(trend_vars.back()) != trend_symbols_map.end())
-      throw TrendException(symbol_table.getName(trend_vars.back()));
+  for (int id : trend_vars)
+    if (trend_symbols_map.find(id) != trend_symbols_map.end())
+      throw TrendException(symbol_table.getName(id));
     else
-      {
-        trend_symbols_map[trend_vars.back()] = growth_factor;
-        trend_vars.pop_back();
-      }
+      trend_symbols_map[id] = growth_factor;
 }
 
 void
-ModelTree::addNonstationaryVariables(vector<int> nonstationary_vars, bool log_deflator, expr_t deflator) noexcept(false)
+ModelTree::addNonstationaryVariables(const vector<int> &nonstationary_vars, bool log_deflator, expr_t deflator) noexcept(false)
 {
-  while (!nonstationary_vars.empty())
-    if (nonstationary_symbols_map.find(nonstationary_vars.back()) != nonstationary_symbols_map.end())
-      throw TrendException(symbol_table.getName(nonstationary_vars.back()));
+  for (int id : nonstationary_vars)
+    if (nonstationary_symbols_map.find(id) != nonstationary_symbols_map.end())
+      throw TrendException(symbol_table.getName(id));
     else
-      {
-        nonstationary_symbols_map[nonstationary_vars.back()] = { log_deflator, deflator };
-        nonstationary_vars.pop_back();
-      }
+      nonstationary_symbols_map[id] = { log_deflator, deflator };
 }
 
 void
diff --git a/src/ModelTree.hh b/src/ModelTree.hh
index ae9aa026f50bfc80155fab84af1e300a27d31e29..0dc0aa5ac185c864240088ab4e4c8e54474292b2 100644
--- a/src/ModelTree.hh
+++ b/src/ModelTree.hh
@@ -343,9 +343,9 @@ public:
   //! Returns the number of equations in the model
   int equation_number() const;
   //! Adds a trend variable with its growth factor
-  void addTrendVariables(vector<int> trend_vars, expr_t growth_factor) noexcept(false);
+  void addTrendVariables(const vector<int> &trend_vars, expr_t growth_factor) noexcept(false);
   //! Adds a nonstationary variables with their (common) deflator
-  void addNonstationaryVariables(vector<int> nonstationary_vars, bool log_deflator, expr_t deflator) noexcept(false);
+  void addNonstationaryVariables(const vector<int> &nonstationary_vars, bool log_deflator, expr_t deflator) noexcept(false);
   //! Is a given variable non-stationary?
   bool isNonstationary(int symb_id) const;
   void set_cutoff_to_zero();