Added authentication failed error check