A better algorithm to determine the count of weak matches