rely on sorting for maxCount