fix for issue #1 - adds a loop to find the best (longest) match...