Build URI function