refactor code -- sequence editor erase with end() check