added the branch selection mechanism