refactoring of the set helper