sanitizeString() function