My mistake. I have changed it back to the way it was after realising the $name node will be updated and we don't need to test the div directly (although that worked in this incarnation).