(mod (CURRENT_METADATA METADATA_UPDATER_PUZZLE_HASH (key . new_url))

  ; METADATA and METADATA_UPDATER_PUZZLE_HASH are passed in as truths from the layer above
  ; This program returns ((new_metadata new_metadata_updater_puzhash) conditions)

  ; Add uri to a field
  (defun add_url (METADATA key new_url)
    (if METADATA
      (if (= (f (f METADATA)) key)
        (c (c key (c new_url (r (f METADATA)))) (r METADATA))
        (c (f METADATA) (add_url (r METADATA) key new_url))
      )
      ()
    )
  )
  ; main
  ; returns ((new_metadata new_metadata_updater_puzhash) conditions)
  (list
    (list
        (if (all key new_url)
            (if (any (= key "mu") (= key "lu") (= key "u"))
                (add_url CURRENT_METADATA key new_url)
                CURRENT_METADATA
            )
            CURRENT_METADATA
         )
        METADATA_UPDATER_PUZZLE_HASH)
    0
  )
)
