diff --git a/mex/sources/bytecode/Evaluate.cc b/mex/sources/bytecode/Evaluate.cc
index 927e46c7103adb1420c1cdb6f73b5561ccc51573..cf5591a0c2b66e41f30f44ab287a309d052c1502 100644
--- a/mex/sources/bytecode/Evaluate.cc
+++ b/mex/sources/bytecode/Evaluate.cc
@@ -323,6 +323,8 @@ Evaluate::error_location(it_code_type expr_begin, it_code_type faulty_op, int it
     case ExpressionType::FirstEndoDerivative:
       Error_loc << " with respect to endogenous variable "
                 << symbol_table.getName(SymbolType::endogenous, EQN_dvar1);
+      if (EQN_lag1 != 0)
+        Error_loc << "(" << EQN_lag1 << ")";
       break;
     case ExpressionType::FirstExoDerivative:
       Error_loc << " with respect to exogenous variable "