diff --git a/matlab/resid.m b/matlab/resid.m
index 499ce144aa3105c4c7c7608e67334fc7b3cd79d8..1e769ffb9d552e4382aed0c9b636343eb291f0de 100644
--- a/matlab/resid.m
+++ b/matlab/resid.m
@@ -77,11 +77,7 @@ if options_.block && ~options_.bytecode
                                      oo_.steady_state,...
                                      [oo_.exo_steady_state; ...
                             oo_.exo_det_steady_state], M_.params);
-        if isempty(M_.blocksMFS{i})
-            idx = var_indx;
-        else
-            idx = M_.blocksMFS{i};
-        end
+        idx = M_.blocksEQU{i};
         z(idx) = r;
     end
 elseif options_.bytecode
diff --git a/preprocessor/StaticModel.cc b/preprocessor/StaticModel.cc
index 7f25803fdd5b34f47046970ce035af715084299e..5a59e9489e80f279d0e430c00832dd4a7f921cd7 100644
--- a/preprocessor/StaticModel.cc
+++ b/preprocessor/StaticModel.cc
@@ -1354,6 +1354,15 @@ StaticModel::writeOutput(ostream &output, bool block) const
 
       output << "];" << endl;
     }
+  output << "M_.blocksEQU = cell(" << nb_blocks << ", 1);" << endl;
+  for (int b = 0; b < (int) nb_blocks; b++)
+    {
+      unsigned int block_size = getBlockSize(b);
+      output << "M_.blocksEQU{" << b+1 << "} = [ ";
+      for (int i = 0; i < (int) block_size; i++)
+         output << getBlockEquationID(b, i)+1 << "; ";
+      output << "];" << endl;
+    }
 }
 
 SymbolType