replaced Dictionary with HashSet