Fixed the code to support authentication failure.