diff --git a/matlab/+gui/+perfect_foresight/run.m b/matlab/+gui/+perfect_foresight/run.m
index ec621928f9f862cab53741e75e9537fa0e771308..5dbc39424032ac6324d93f05c89c1cccc574586f 100644
--- a/matlab/+gui/+perfect_foresight/run.m
+++ b/matlab/+gui/+perfect_foresight/run.m
@@ -42,7 +42,7 @@ if nargout > 1
 end
 
 %% Read JSON
-jm = loadjson(json, 'SimplifyCell', 0);
+jm = loadjson(json, 'SimplifyCell', 1);
 
 %% INITVAL instructions
 % initialize exogenous shocks to zero and compute initial steady state
@@ -107,7 +107,8 @@ if isfield(jm, 'transitory_shocks') && ~isempty(jm.transitory_shocks)
     M_.exo_det_length = 0;
 end
 
-if jm.nonanticipatedshockexist == 1 || jm.delayexist == 1
+if isfield(jm, 'unanticipated_shocks') && ~isempty(jm.unanticipated_shocks) ...
+        || isfield(jm, 'expected_date') && ~isempty(jm.expected_date)
     nonanticip = jm.nonanticipmatrix;
     rowindex = 1;
     firstsimul = 0;
@@ -117,10 +118,24 @@ if jm.nonanticipatedshockexist == 1 || jm.delayexist == 1
             % there are nonanticipated shocks to add at first period
             if nonanticip{rowindex}{4} == 0
                 % this is a current nonanticipated shock
-                M_.det_shocks = [ M_.det_shocks;struct('exo_det',0,'exo_id',(nonanticip{rowindex}{2}+1),'multiplicative',0,'periods',1:1,'value',nonanticip{rowindex}{7}) ];
+                M_.det_shocks = [ ...
+                    M_.det_shocks; ...
+                    struct( ...
+                    'exo_det', 0, ...
+                    'exo_id', nonanticip{rowindex}{2}+1, ...
+                    'multiplicative', 0, ...
+                    'periods', 1:1, ...
+                    'value',nonanticip{rowindex}{7})];
             else
                 % this is a delayed nonanticipated shock
-                M_.det_shocks = [ M_.det_shocks;struct('exo_det',0,'exo_id',(nonanticip{rowindex}{2}+1),'multiplicative',0,'periods',(nonanticip{rowindex}{5}):(nonanticip{rowindex}{6}),'value',nonanticip{rowindex}{7}) ];
+                M_.det_shocks = [ ...
+                    M_.det_shocks; ...
+                    struct( ...
+                    'exo_det', 0, ...
+                    'exo_id', nonanticip{rowindex}{2}+1, ...
+                    'multiplicative', 0, ...
+                    'periods', nonanticip{rowindex}{5}:nonanticip{rowindex}{6}, ...
+                    'value', nonanticip{rowindex}{7})];
             end
             if nonanticip{rowindex+1}{1} ~= currentperiod
                 % when we have tracked all first period shocks we can simulate