updated exractByMid to look for back sequences