Extracted common logic between table view and segmented control