simplify calculation of character counts