modified logic for branch selector