fixed the count of patterns