Index: trunk/MagicSoft/Mars/mbadpixels/MBadPixelsCam.cc
===================================================================
--- trunk/MagicSoft/Mars/mbadpixels/MBadPixelsCam.cc	(revision 4678)
+++ trunk/MagicSoft/Mars/mbadpixels/MBadPixelsCam.cc	(revision 4679)
@@ -201,4 +201,23 @@
 // --------------------------------------------------------------------------
 //
+// Counts the number of neighbors matching NOT UnsuitableType type
+//
+Short_t MBadPixelsCam::GetNumSuitableNeighbors(MBadPixelsPix::UnsuitableType_t type, const MGeomPix &pix) const
+{
+    const Int_t n2 = pix.GetNumNeighbors();
+
+    Int_t cnt=0;
+    for (int j=0; j<n2; j++)
+    {
+        const Int_t id2 = pix.GetNeighbor(j);
+        if (!(*this)[id2].IsUnsuitable(type))
+            cnt++;
+    }
+
+    return cnt;
+}
+
+// --------------------------------------------------------------------------
+//
 // Calculate the number of pixels which are - under no circumstances -
 // interpolatable, called isolated. This means that a pixel (its own status
@@ -227,15 +246,5 @@
             continue;
 
-        const Int_t n2 = pix.GetNumNeighbors();
-
-        Int_t cnt=0;
-        for (int j=0; j<n2; j++)
-        {
-            const Int_t id2 = pix.GetNeighbor(j);
-            if (!(*this)[id2].IsUnsuitable(type))
-                cnt++;
-        }
-
-        if (cnt<2)
+        if (GetNumSuitableNeighbors(type, pix)<2)
             rc++;
     }
@@ -262,5 +271,5 @@
         return 0;
 
-    if (!(*this)[idx].IsUnsuitable(type))
+    if (GetNumSuitableNeighbors(type, *pix)>1)
         return 0;
 
Index: trunk/MagicSoft/Mars/mbadpixels/MBadPixelsCam.h
===================================================================
--- trunk/MagicSoft/Mars/mbadpixels/MBadPixelsCam.h	(revision 4678)
+++ trunk/MagicSoft/Mars/mbadpixels/MBadPixelsCam.h	(revision 4679)
@@ -9,4 +9,5 @@
 #endif
 
+class MGeomPix;
 class TClonesArray;
 
@@ -16,4 +17,5 @@
     TClonesArray *fArray; //-> 
 
+    Short_t GetNumSuitableNeighbors(MBadPixelsPix::UnsuitableType_t type, const MGeomPix &pix) const;
     Short_t GetNumMaxCluster(MBadPixelsPix::UnsuitableType_t type, TObjArray &list, Int_t idx, Int_t aidx) const;
 
