refeactoring seq_gen, yielding output instead of prinitng