Refactored Tabs logic