Convert some if statements to ternaries