Added better stop logic