Added better stoping code