refactor sequence matcher & test