added some parens to clear up the nested ternary operators