Adding stop condition for circular search