sorry overlooked this: this needs to be ```if (type.length)``` or you need to use ```ZU.xpathText``` above. ```ZU.xpath``` is always true.