refactor out set duplication with apply hashset