frequency count implementation