fixed mistakes with overlapping matches