diff --git a/pyfstat.py b/pyfstat.py
index 6442f3acf38f649afcb30d0f2b1e97f775b1be1f..4509aa1c613cbaa5e8824f7a2f1b08d4f192768a 100755
--- a/pyfstat.py
+++ b/pyfstat.py
@@ -374,7 +374,10 @@ class SemiCoherentGlitchSearch(BaseSearchClass, ComputeFstat):
                 theta_i_at_tref[3], Alpha, Delta)
             twoFSum += twoFVal
 
-        return twoFSum
+        if np.isfinite(twoFSum):
+            return twoFSum
+        else:
+            return 0
 
     def compute_glitch_fstat_single(self, F0, F1, F2, Alpha, Delta, delta_F0,
                                     delta_F1, tglitch):