an algorithm for powerset