diff --git a/Mesh/HighOrder.cpp b/Mesh/HighOrder.cpp
index 6c8b2a09188b2332e71a5351f8d0b8b1e0392beb..ab6ad3ff14128cff78ba48df59ef9756ea8b5dc3 100644
--- a/Mesh/HighOrder.cpp
+++ b/Mesh/HighOrder.cpp
@@ -1350,6 +1350,8 @@ void SetOrderN(GModel *m, int order, bool linear, bool incomplete)
     setHighOrder(*it, edgeVertices, faceVertices, linear, incomplete, nPts,
                  displ2D, displ3D);
 
+  highOrderTools hot (m);
+
   // now we smooth mesh the internal vertices of the faces
   // we do that model face by model face
   std::vector<MElement*> bad;
@@ -1383,7 +1385,6 @@ void SetOrderN(GModel *m, int order, bool linear, bool incomplete)
   double t2 = Cpu();
 
   if (!linear){
-    highOrderTools hot (m);
     hot.ensureMinimumDistorsion(0.1);
     checkHighOrderTriangles("final mesh", m, bad, worst);
   }
diff --git a/Mesh/highOrderTools.cpp b/Mesh/highOrderTools.cpp
index 5c8df2bf5757ccd8f5b470463f93d13499cc33b9..cf46a8b496ac4daaf8e6672c21e7516a7c33a2e2 100644
--- a/Mesh/highOrderTools.cpp
+++ b/Mesh/highOrderTools.cpp
@@ -73,8 +73,10 @@ void highOrderTools::ensureMinimumDistorsion(MElement *e, double threshold)
   }
   // a == 0 -> straight
   // a == 1 -> curved
+  int ITER = 1;
   while(1){
     double a = 0.5*(a1+a2);
+    if (ITER > 10) a = 0.;
     for(int i = 0; i < e->getNumVertices(); i++){
       MVertex *v = e->getVertex(i);
       v->x() = a * x[i][0] + (1.-a) * X[i][0]; 
@@ -87,6 +89,8 @@ void highOrderTools::ensureMinimumDistorsion(MElement *e, double threshold)
     if (dist > 0 && fabs(dist-threshold) < .05)break;
     if (dist < threshold)a2 = a;
     else a1 = a;    
+    if (a > .99 || a < .01) break;
+    ++ITER;
   }
   //  printf("element done\n");
 }
@@ -612,11 +616,14 @@ double highOrderTools::apply_incremental_displacement (double max_incr,
 // uncurve elements that are invalid
 void highOrderTools::ensureMinimumDistorsion (std::vector<MElement*> &all, 
 					      double threshold){
+  int num = 0;
   while(1){
     double minD;
     std::vector<MElement*> disto;
     getDistordedElements(all, threshold, disto, minD);    
+    if (num == disto.size())break;
     if (!disto.size())break;
+    num = disto.size();
     Msg::Info("fixing %d bad curved elements (worst disto %g)",disto.size(),minD);
     for (int i=0;i<disto.size();i++){
       ensureMinimumDistorsion(disto[i],threshold);