Fixed bug in sequence generation