fixed the counts code