refactoring from calling extract() on untrusted data