refactor char_count for readability