Modifying extendMatch to act more like the process of extending matches in find_match in the C++ code