diff --git a/matlab/nonlinear-filters/nonlinear_kalman_filter.m b/matlab/nonlinear-filters/nonlinear_kalman_filter.m
index 27dbae5c69bb7126460440ce8d561c6d622e3e68..ba7aacc99afd7f5cc107297bbc71d93cd316dca6 100644
--- a/matlab/nonlinear-filters/nonlinear_kalman_filter.m
+++ b/matlab/nonlinear-filters/nonlinear_kalman_filter.m
@@ -92,6 +92,8 @@ number_of_state_variables = length(mf0);
 number_of_observed_variables = length(mf1);
 number_of_structural_innovations = length(ReducedForm.Q);
 
+pruning = ParticleOptions.pruning;
+
 % compute gaussian quadrature nodes and weights on states and shocks
 if ParticleOptions.proposal_approximation.montecarlo
     nodes = randn(ParticleOptions.number_of_particles,number_of_state_variables+number_of_structural_innovations);
@@ -145,7 +147,7 @@ for t=1:sample_size
           case 2
             tmp = local_state_space_iteration_2(yhat,epsilon,ghx,ghu,constant,ghxx,ghuu,ghxu,ThreadsOptions.local_state_space_iteration_2);
           case 3
-            tmp = local_state_space_iteration_3(yhat, epsilon, ghx, ghu, ghxx, ghuu, ghxu, ghs2, ghxxx, ghuuu, ghxxu, ghxuu, ghxss, ghuss, steadystate, ThreadsOptions.local_state_space_iteration_3, pruning);
+            tmp = local_state_space_iteration_3(yhat, epsilon, ghx, ghu, ghxx, ghuu, ghxu, ghs2, ghxxx, ghuuu, ghxxu, ghxuu, ghxss, ghuss, steadystate, ThreadsOptions.local_state_space_iteration_3,pruning);
           otherwise
             error('Order > 3: use_k_order_solver should be set to true');
         end
@@ -181,13 +183,12 @@ for t=1:sample_size
             lik(t)=-Inf;
             return
         end
-        [~, p]= chol(PredictedObservedVariance,'lower');
+        [PredictedObservedVarianceSquareRoot, p]= chol(PredictedObservedVariance,'lower');
         if p
             LIK=-Inf;
             lik(t)=-Inf;
             return
         end
-        PredictedObservedVarianceSquareRoot = chol(PredictedObservedVariance);
     end
     PredictedObservedInverseVarianceSquareRoot = PredictedObservedVarianceSquareRoot\eye(n); % Inverse of the Cholesky -> inv(PredictedObservedVariance) = A*A'
     StandardPredictionError = PredictedObservedInverseVarianceSquareRoot'*PredictionError;