refactored tv mode controller code