refactored explore xpath routine