I guess this can be replaced with something without (n,n) arrays
unless subset is always small