added a guard to  wrappers, check the element.nodeType