fix next index backward after matched bug