factor out the text sanitizing function