Fix minor issue in tab switching logic