Fix order of repository lookup