Extract package discovery to separate method