refactoring global wrap handler