add subsets algorithm