improved efficiency of replaceSymbols