replace repetitive code in add_back_links_to_dom by three calls to a local function