added 2nd if to ternary