We need to get the data object for each state (which involves inspecting the keys of each data object, to make sure we have the property `data[j]`). Then only for that object we should add all the keys. The check `k !== key` was not necessary, so I just removed it, I think that's what might have been confusing.