diff --git a/matlab/set_prior.m b/matlab/set_prior.m
index 66633792c2cb78e0b59afbfec457fc2f598a8c6a..b5b720b5784b590d8e1cee64849d211f7dadd22d 100644
--- a/matlab/set_prior.m
+++ b/matlab/set_prior.m
@@ -55,7 +55,7 @@ bayestopt_.p1 = []; % prior mean
 bayestopt_.p2 = []; % prior standard deviation
 bayestopt_.p3 = []; % lower bound
 bayestopt_.p4 = []; % upper bound
-bayestopt_.p5 = []; % prior mode
+bayestopt_.p5 = zeros(nvx+nvn+ncx+ncn+np,1); % prior mode
 bayestopt_.p6 = []; % first hyper-parameter (\alpha for the BETA and GAMMA distributions, s for the INVERSE GAMMAs, expectation for the GAUSSIAN distribution, lower bound for the UNIFORM distribution).
 bayestopt_.p7 = []; % second hyper-parameter (\beta for the BETA and GAMMA distributions, \nu for the INVERSE GAMMAs, standard deviation for the GAUSSIAN distribution, upper bound for the UNIFORM distribution).
 
@@ -261,23 +261,17 @@ if exist([ M_.dname '/prior/definition.mat'])
     if length(bayestopt_.p1)==length(old.bayestopt_.p1)
         if any(bayestopt_.p1-old.bayestopt_.p1)
             prior_has_changed = 1;
-        end
-        if any(bayestopt_.p2-old.bayestopt_.p2)
+        elseif any(bayestopt_.p2-old.bayestopt_.p2)
             prior_has_changed = 1;
-        end
-        if any(bayestopt_.p3-old.bayestopt_.p3)
+        elseif any(bayestopt_.p3-old.bayestopt_.p3)
             prior_has_changed = 1;
-        end
-        if any(bayestopt_.p4-old.bayestopt_.p4)
+        elseif any(bayestopt_.p4-old.bayestopt_.p4)
             prior_has_changed = 1;
-        end
-        if any(bayestopt_.p5-old.bayestopt_.p5)
+        elseif any(bayestopt_.p5-old.bayestopt_.p5(:))
             prior_has_changed = 1;
-        end
-        if any(bayestopt_.p6-old.bayestopt_.p6)
+        elseif any(bayestopt_.p6-old.bayestopt_.p6)
             prior_has_changed = 1;
-        end
-        if any(bayestopt_.p7-old.bayestopt_.p7)
+        elseif any(bayestopt_.p7-old.bayestopt_.p7)
             prior_has_changed = 1;
         end
     else