a little less opaque
add function to check cardinality
cleanup