more refactoring to avoid errors wrt namespaces and xpath