escape() refactoring