working now, but bug still

the output has duplicated chars,
like abbbb, the total number is 120 which is correct.