switched ternary logic