Fixed a bug with backtracking after adding a match