Moved text sanitisation into seperate function