nullpointer bug based upon bad ternary logic