refactored sequence generation