Improved code when repeating chars