removed unnecessary char replace and instead use char_replace()