fix bug: did not use the ternary operator correctly