need also a check in the else block of the if (cId == 0) condition that mIdentity != null after the call to existingIdentity.