changed nodeType verification added check for frag to exist