Changed stop criterion to better suit the simulation.