refactor iSequence code using visitor pattern