adjusted login so error message is only passed if an error happened