refactor: no need to call cardinalities, instead check the shape of vals narray