added stop ranging logic