refactoring seq.py