fix match count logic