generate sequence function