     acc
     |> Enum.sort()
     |> Enum.find_value(&parse_header_accept(conn, &1, accepted))
-    |> Kernel.||(refuse(conn, accepted))
-  end
-
-  defp parse_header_accept(conn, {_, exts}, accepted) do
+    |> Kernel.||(refuse(conn, acc, accepted))
+  end
+
+  defp parse_header_accept(conn, {_, _, exts}, accepted) do
     if format = find_format(exts, accepted) do
       put_format(conn, format)
     end

        if format = (q === 1.0 && find_format(exts, accepted)) do
          put_format(conn, format)
        else
          parse_header_accept(conn, t, [{-q, exts}|acc], accepted)
        end
      :error ->
        parse_header_accept(conn, t, acc, accepted)

    end
  end

  @spec refuse(term(), [tuple], [binary]) :: no_return()
  defp refuse(_conn, given, accepted) do
    raise Phoenix.NotAcceptableError,
      accepts: accepted,
      message: """
      no supported media type in accept header.

      Expected one of #{inspect accepted} but got the following formats:

        * #{Enum.map_join(given, "\n  ", fn {_, header, exts} ->
              inspect(header) <> " with extensions: " <> inspect(exts)
            end)}

      To accept custom formats, register its extensions in the `:mime` library:

          config :mime, :types, %{
            "application/xml" => ["xml"]
          }

      And then run `mix deps.clean --build mime` to force it to be recompiled.
      """
  end

  @doc """
