counts character by type
fixed indentaion issue