modularize the counting of the counts