diff --git a/src/macro/Environment.cc b/src/macro/Environment.cc
index 041011d27e65fa1a3bc0b367021a754c1f6d02ce..4a0d1c0c6683c2e9b7bb994842b2280944de384b 100644
--- a/src/macro/Environment.cc
+++ b/src/macro/Environment.cc
@@ -1,5 +1,5 @@
 /*
- * Copyright © 2019-2023 Dynare Team
+ * Copyright © 2019-2024 Dynare Team
  *
  * This file is part of Dynare.
  *
@@ -54,7 +54,7 @@ Environment::getVariable(const string& name) const
   return getGlobalEnv()->getVariable(name);
 }
 
-tuple<FunctionPtr, ExpressionPtr>
+pair<FunctionPtr, ExpressionPtr>
 Environment::getFunction(const string& name) const
 {
   if (auto it = functions.find(name); it != functions.end())
@@ -120,11 +120,11 @@ Environment::print(ostream& output, const vector<string>& vars, const optional<i
 
   if (vars.empty())
     for (const auto& it : functions)
-      printFunction(output, it.second, line, save);
+      printFunction(output, it.first, line, save);
   else
     for (const auto& it : vars)
       if (isFunctionDefined(it))
-        printFunction(output, functions.at(it), line, save);
+        printFunction(output, it, line, save);
 
   if (parent)
     parent->print(output, vars, line, save);
@@ -143,20 +143,21 @@ Environment::printVariable(ostream& output, const string& name, const optional<i
 }
 
 void
-Environment::printFunction(ostream& output, const tuple<FunctionPtr, ExpressionPtr>& function,
-                           const optional<int>& line, bool save) const
+Environment::printFunction(ostream& output, const string& name, const optional<int>& line,
+                           bool save) const
 {
   assert(!save || line);
+  auto [func_signature, func_body] = getFunction(name);
   output << (save ? "options_.macrovars_line_" + to_string(*line) + ".function." : "  ");
   if (save)
     {
-      get<0>(function)->printName(output);
+      func_signature->printName(output);
       output << " = '";
     }
 
-  get<0>(function)->print(output);
+  func_signature->print(output);
   output << " = ";
-  get<1>(function)->print(output);
+  func_body->print(output);
 
   if (save)
     output << "';";
diff --git a/src/macro/Environment.hh b/src/macro/Environment.hh
index f55dd16323baca1b71ad04e59a61ff15086b633e..4a807cdd9213db14419cd65f26f5df41781890c5 100644
--- a/src/macro/Environment.hh
+++ b/src/macro/Environment.hh
@@ -1,5 +1,5 @@
 /*
- * Copyright © 2019-2023 Dynare Team
+ * Copyright © 2019-2024 Dynare Team
  *
  * This file is part of Dynare.
  *
@@ -33,7 +33,7 @@ class Environment
 private:
   const Environment* parent {nullptr};
   map<string, ExpressionPtr> variables;
-  map<string, tuple<FunctionPtr, ExpressionPtr>> functions;
+  map<string, pair<FunctionPtr, ExpressionPtr>> functions;
 
 public:
   Environment() = default;
@@ -45,7 +45,7 @@ public:
   /* The following two functions are not marked [[nodiscard]], because they are used without output
      to check whether they return an exception or not. */
   ExpressionPtr getVariable(const string& name) const; // NOLINT(modernize-use-nodiscard)
-  tuple<FunctionPtr, ExpressionPtr>                    // NOLINT(modernize-use-nodiscard)
+  pair<FunctionPtr, ExpressionPtr>                     // NOLINT(modernize-use-nodiscard)
   getFunction(const string& name) const;
   [[nodiscard]] codes::BaseType getType(const string& name) const;
   [[nodiscard]] bool isVariableDefined(const string& name) const noexcept;
@@ -59,8 +59,8 @@ public:
              bool save = false) const;
   void printVariable(ostream& output, const string& name, const optional<int>& line,
                      bool save) const;
-  void printFunction(ostream& output, const tuple<FunctionPtr, ExpressionPtr>& function,
-                     const optional<int>& line, bool save) const;
+  void printFunction(ostream& output, const string& name, const optional<int>& line,
+                     bool save) const;
   [[nodiscard]] size_t
   size() const noexcept
   {