better branch handling