removeRareChars function added