Optimize repeating characters

optimizes repeated characters