Added ternary statement to the code.