change the way to generate and stop