refactor seq code