calculating match counts