diff --git a/matlab/evaluate_steady_state.m b/matlab/evaluate_steady_state.m
index e5a6c7a472c6b37aa51045692b903c49b5838e1e..764c7dbab04b04273740f1ae29e2d1c24c4cadc2 100644
--- a/matlab/evaluate_steady_state.m
+++ b/matlab/evaluate_steady_state.m
@@ -426,7 +426,7 @@ elseif options_.bytecode
             % Also update the temporary terms vector (needed for the dynare_solve case)
             try
                 [~, ~, ys, T] = bytecode(M_, options_, ys, exo_ss, params, ys, 1, ys, T, 'evaluate', 'static', ...
-                                         'block_decomposed', ['block = ' int2str(b)]);
+                                         'block_decomposed', ['block=' int2str(b)]);
             catch ME
                 if options_.verbosity >= 1
                     disp(ME.message);
@@ -521,5 +521,5 @@ function [r, g1] = block_bytecode_mfs_steadystate(y, b, y_all, exo, params, T, M
 % Wrapper around the static files, for bytecode with block
 mfs_idx = M_.block_structure_stat.block(b).variable(end-M_.block_structure_stat.block(b).mfs+1:end);
 y_all(mfs_idx) = y;
-[r, g1] = bytecode(M_, options_, y_all, exo, params, y_all, 1, y_all, T, 'evaluate', 'static', 'block_decomposed', ['block = ' int2str(b) ]);
+[r, g1] = bytecode(M_, options_, y_all, exo, params, y_all, 1, y_all, T, 'evaluate', 'static', 'block_decomposed', ['block=' int2str(b) ]);
 g1 = g1(:,end-M_.block_structure_stat.block(b).mfs+1:end); % Make Jacobian square if mfs>0
diff --git a/mex/sources/bytecode/bytecode.cc b/mex/sources/bytecode/bytecode.cc
index accd4f5465db4d11ea73b46665df6087b29a1cea..1bed2a1b79e7238af19728d4d1826a61f2ff23ae 100644
--- a/mex/sources/bytecode/bytecode.cc
+++ b/mex/sources/bytecode/bytecode.cc
@@ -65,7 +65,6 @@ Get_Arguments_and_global_variables(int nrhs,
                                    bool *extended_path, mxArray **ep_struct)
 {
   int count_array_argument {0};
-  size_t pos;
   *extended_path = false;
   for (int i = 0; i < nrhs; i++)
     {
@@ -132,15 +131,16 @@ Get_Arguments_and_global_variables(int nrhs,
           print = true;
         else
           {
-            pos = 0;
-            if (Get_Argument(prhs[i]).substr(0, 5) == "block")
+            if (Get_Argument(prhs[i]).substr(0, 6) == "block=")
               {
-                size_t pos1 = Get_Argument(prhs[i]).find("=", pos + 5);
-                if (pos1 != string::npos)
-                  pos = pos1 + 1;
-                else
-                  pos += 5;
-                block = atoi(Get_Argument(prhs[i]).substr(pos, string::npos).c_str())-1;
+                try
+                  {
+                    block = stoi(Get_Argument(prhs[i]).substr(6))-1;
+                  }
+                catch (...)
+                  {
+                    throw FatalException{"ERROR: incorrect syntax for the 'block=' option"};
+                  }
               }
             else if (Get_Argument(prhs[i]).substr(0, 13) == "extended_path")
               {