changed < to <= in countPair