Fixing NullPointerException in calculating IdentityFields