fix bug in updateCharCount