diff --git a/Plugin/MathEval.cpp b/Plugin/MathEval.cpp
index 1e52daa25cb25b500939d2e457f2701d746b808b..9c232aa5ca92097b7211227277230f36bb25cf52 100644
--- a/Plugin/MathEval.cpp
+++ b/Plugin/MathEval.cpp
@@ -126,14 +126,6 @@ PView *GMSH_MathEvalPlugin::execute(PView *view)
     return view;
   }
 
-  OctreePost *octree = 0;
-  if(forceInterpolation ||
-     (data1->getNumEntities() != otherData->getNumEntities()) ||
-     (data1->getNumElements() != otherData->getNumElements())){
-    Msg::Info("Other view based on different grid: interpolating...");
-    octree = new OctreePost(otherView);
-  }
-
   if(otherTimeStep < 0 && otherData->getNumTimeSteps() != data1->getNumTimeSteps()){
     Msg::Error("Number of time steps don't match: using step 0");
     otherTimeStep = 0;
@@ -171,6 +163,14 @@ PView *GMSH_MathEvalPlugin::execute(PView *view)
   if(expr.empty()) return view;
   std::vector<double> values(numVariables), res(numComp2);
 
+  OctreePost *octree = 0;
+  if(forceInterpolation ||
+     (data1->getNumEntities() != otherData->getNumEntities()) ||
+     (data1->getNumElements() != otherData->getNumElements())){
+    Msg::Info("Other view based on different grid: interpolating...");
+    octree = new OctreePost(otherView);
+  }
+
   PView *v2 = new PView();
   PViewDataList *data2 = getDataList(v2);
 
@@ -236,14 +236,19 @@ PView *GMSH_MathEvalPlugin::execute(PView *view)
           values[0] = x[nod]; values[1] = y[nod]; values[2] = z[nod];
           for(int i = 0; i < 9; i++) values[3 + i] = v[i];
           for(int i = 0; i < 9; i++) values[12 + i] = w[i];
-          if(f.eval(values, res))
+          if(f.eval(values, res)){
             for(int i = 0; i < numComp2; i++)
               out->push_back(res[i]);
+          }
+          else{
+            goto end;
+          }
         }
       }
     }
   }
 
+ end:
   if(octree) delete octree;
 
   if(timeStep < 0){