Corrected bug on ternary