added stop logic