update to handle namespace in agency element, and add fallback