Rewrite name-finding function for copying