applied a Ternary Operator

change if and else to Ternary code