Extract dependency logic into its own method.