Refactor looking up dependencies