refactoring the sequence class