fixed count_chars()