refactoring code and include test for seq sanity check