rewriting to work over hashset