 
   """
   @spec intersection(t, t) :: t
-  def intersection(%MapSet{} = set1, %MapSet{} = set2) do
-    if size(set1) > size(set2), do: {set1, set2} = {set2, set1}
-    reduce(set1, {:cont, new}, fn value, acc ->
-      if member?(set2, value) do
-        {:cont, put(acc, value)}
+  def intersection(%MapSet{map: map1}, %MapSet{map: map2}) do
+    if map_size(map1) > map_size(map2), do: {map1, map2} = {map2, map1}
+    map = :maps.fold(fn value, _, acc ->
+      if Map.has_key?(map2, value) do
+        Map.put(acc, value, true)
       else
-        {:cont, acc}
+        acc
       end
-    end) |> elem(1)
+    end, %{}, map1)
+    %MapSet{map: map}
   end
 
   @doc """

  """

  @opaque t :: %__MODULE__{map: map}
  defstruct map: %{}

  @doc """


  """
  @spec difference(t, t) :: t
  def difference(%MapSet{map: map1}, %MapSet{map: map2}) do
    map = :maps.fold(fn value, _, acc ->
      Map.delete(acc, value)
    end, map1, map2)
    %MapSet{map: map}
  end

  @doc """
