fix nasty ternary bug