refactor refs_from_alternate_cb to allow passing extra data