finished countCharOccur function