refactors sanitizer to be more flexible