corrected the counting of characters