fixed bug in countChars