factor out uri-expansion and proc-lookup