Refactored authenticate in a ternary