refactoring for hashset