     case get(url) do
       {:ok, response} ->
         if redirect?(response.status_code) do
-          Logger.debug("will redirect " <> redirect_location(response.headers))
-          get_with_redirects(resolve_url(redirect_location(response.headers), url))
+          get_with_redirects(resolve_url(get_header(response.headers, "Location"), url))
         else
           {:ok, response}
         end

defmodule FourOhFourFinderApp.PageAnalyzer do
  use HTTPoison.Base
  require Logger

  def analyze(url) do
    case get_with_redirects(url) do
      {:ok, %HTTPoison.Response{status_code: code, body: body}} ->
        html = Floki.parse(body)
        if good_resp?(code) do
          %{
            url: url,
            http_status: code,
            success: true,
            outgoing_hrefs: tree_hrefs(html, url),
            ids: tree_ids(html)
          }
        else
          %{ url: url, http_status: code, success: false }
        end

    end
  end

  def is_html(response) do
    String.starts_with?(get_header(response.headers, "content-type"), "text/html")
  end

  def get_header(headers, header_name) do
    elem(Enum.find(headers, fn({header, _}) -> String.downcase(header_name) == String.downcase(header) end), 1)
  end

  def good_resp?(code) do
