Sequence generation bug fix