added alg for num matches