refactor generateURNForNode for better msg in error case and also for maintainability.