diff --git a/modelling/pymod/_closegaps.py b/modelling/pymod/_closegaps.py
index 337c281b22c3fee1b9a14cd941fd12e6009b3a55..7e6a730d5cae09ddf81dba6122b0dabfd1a6a95e 100644
--- a/modelling/pymod/_closegaps.py
+++ b/modelling/pymod/_closegaps.py
@@ -1047,7 +1047,7 @@ def FillLoopsByMonteCarlo(mhandle, torsion_sampler=None, max_loops_to_search=6,
         ext_step = 0
 
         first_iteration = True
-        while found_loops < max_loops_to_search and ext_step < max_extension:
+        while found_loops < max_loops_to_search and ext_step <= max_extension:
 
             # extend the gap
             if not first_iteration: