factor out sanitization