implemented next sequence generation