Added ternary operation to handle the function.