remove a bug in add_refs function