Refactored branch selection logic into a separate interface