Small fix to the tab selection code