Replaced continue with break in proximity search (incorrectly translated from Python)