diff --git a/matlab/independent_metropolis_hastings_core.m b/matlab/independent_metropolis_hastings_core.m
index 829cf4006c0a99371c298ded7e7e41f24fd960aa..04b2683aa0a76c75122ca128a161eb5b06652a4a 100644
--- a/matlab/independent_metropolis_hastings_core.m
+++ b/matlab/independent_metropolis_hastings_core.m
@@ -105,13 +105,19 @@ for b = fblck:nblck,
         % this will not work if the master uses a random generator not
         % available in the slave (different Matlab version or
         % Matlab/Octave cluster). Therefor the trap.
-        set_dynare_seed(options_.DynareRandomStreams.algo);
+        
+        % this set the random generator type (the seed is useless but
+        % needed by the function)
+        set_dynare_seed(options_.DynareRandomStreams.algo,...
+                        options_.DynareRandomStreams.seed);
+        % this set the state 
         set_dynare_random_generator_state(record.Seeds(b).Unifor, ...
                                           record.Seeds(b).Normal);
     catch
+        % if the state set by master is incompatible with the slave, we
+        % only reseed 
         set_dynare_seed(options_.DynareRandomStreams.seed+b);
     end
-    set_dynare_random_generator_state(record.Seeds(b).Unifor,record.Seeds(b).Normal);
     if (options_.load_mh_file~=0)  && (fline(b)>1) && OpenOldFile(b)
         load(['./' MhDirectoryName '/' ModelName '_mh' int2str(NewFile(b)) ...
               '_blck' int2str(b) '.mat'])
diff --git a/matlab/random_walk_metropolis_hastings_core.m b/matlab/random_walk_metropolis_hastings_core.m
index 0cc32ef9fbef50a2a45802cb2d01be3cd36de9f7..8f643d6250fd1fa33c6db5c2e24b43368f9781cc 100644
--- a/matlab/random_walk_metropolis_hastings_core.m
+++ b/matlab/random_walk_metropolis_hastings_core.m
@@ -139,10 +139,17 @@ for b = fblck:nblck,
         % this will not work if the master uses a random generator not
         % available in the slave (different Matlab version or
         % Matlab/Octave cluster). Therefor the trap.
-        set_dynare_seed(options_.DynareRandomStreams.algo);
+        
+        % this set the random generator type (the seed is useless but
+        % needed by the function)
+        set_dynare_seed(options_.DynareRandomStreams.algo,...
+                        options_.DynareRandomStreams.seed);
+        % this set the state 
         set_dynare_random_generator_state(record.Seeds(b).Unifor, ...
                                           record.Seeds(b).Normal);
     catch
+        % if the state set by master is incompatible with the slave, we
+        % only reseed 
         set_dynare_seed(options_.DynareRandomStreams.seed+b);
     end
     if (options_.load_mh_file~=0) && (fline(b)>1) && OpenOldFile(b)