refactor find_refs to make the next change a bit easier