Simplify this block with ternary.