Fixed ternary if bug