Added authentication logic