more robust tab switching