Improve the sanitization code