Fixed a bug that causes repeated addition of the final match in a sequence that ends with a match