fixed overcounting

fixed overcounting when counting the pairs