def METHOD_NAME(rg_working, rg_to_insert):
  # Rigid-body superpose rings
  atoms_fixed  = []
  atoms_moving = []
  for n in non_h_ring_atom_names:
    for atom_to_insert in rg_to_insert.atoms():
      if(atom_to_insert.name.strip().upper() == n):
        atoms_moving.append(atom_to_insert)
    for atom_working in rg_working.atoms():
      if(atom_working.name.strip().upper() == n):
        atoms_fixed.append(atom_working)
  sites_fixed  = flex.vec3_double([a.xyz for a in atoms_fixed])
  sites_moving = flex.vec3_double([a.xyz for a in atoms_moving])
  lsq_fit_obj = superpose.least_squares_fit(
    reference_sites = sites_fixed,
    other_sites     = sites_moving)
  sites_moved = lsq_fit_obj.r.elems*rg_to_insert.atoms().extract_xyz()+lsq_fit_obj.t.elems
  # Overlay ring
  for i, atom_moving in enumerate(rg_to_insert.atoms()):
    atom_moving.set_xyz(sites_moved[i])
  # Then match the rest
  for atom_to_insert in rg_to_insert.atoms():
    for atom_working in rg_working.atoms():
      if(atom_to_insert.name.strip().upper() !=
           atom_working.name.strip().upper()): continue
      atom_to_insert.set_xyz(atom_working.xyz)
      atom_to_insert.set_b(atom_working.b)
      atom_to_insert.set_charge(atom_working.charge)
      atom_to_insert.set_fdp(atom_working.fdp)
      atom_to_insert.set_fp(atom_working.fp)
      atom_to_insert.set_occ(atom_working.occ)
      atom_to_insert.set_segid(atom_working.segid)
      atom_to_insert.set_serial(atom_working.serial)
      atom_to_insert.set_uij(atom_working.uij)
      if(not atom_to_insert.name.strip().upper() in non_h_ring_atom_names):
        atom_to_insert.set_xyz(atom_working.xyz)