Modified authentication handler logic