Refactored the stop sequence generation