       |> String.to_char_list()
       |> List.to_integer(16)
 
-    case size do
-      2 -> ptr = ptr + 2048
-      3 -> ptr = ptr + 526336
-      _ -> nil
+    ptr = case size do
+      2 -> ptr + 2048
+      3 -> ptr + 526336
+      _ -> ptr
     end
 
     { ptr_data, _ } = decode(data, ptr)

    decode_by_type(:uint64, ctrl_code, data, offset)
  end
  defp decode_by_type(:uint64, ctrl_code, data, offset) do
    { size, offset } = ctrl_code |> get_meta_size(data, offset)

    decode_uint(size, data, offset)
  end
  defp decode_by_type(:utf8_string, ctrl_code, data, offset) do
    { size, offset } = ctrl_code |> get_meta_size(data, offset)

    decode_utf8_string(size, data, offset)
  end
  defp decode_by_type(ctrl_type, ctrl_code, data, offset) do
    IO.puts "unhandled type: #{ctrl_type}"

    { _,   offset } = ctrl_code |> get_meta_size(data, offset)
    { nil, offset }
  end


  end

  defp decode_array(arr, size, data, offset) when 0 < size do
    { elem, offset } = decode(data, offset)

    decode_array(arr ++ [elem], size - 1, data, offset)
  end
  defp decode_array(arr, 0, _, offset), do: { arr, offset }

  defp decode_double(size, data, offset) when 0 < size do
    << decoded :: size(64)-float >> = binary_part(data, offset, size)

    { decoded, offset + size }
  end
  defp decode_double(0, _, offset), do: { 0.0, offset }

  defp decode_float(size, data, offset) when 0 < size do
    << decoded :: size(32)-float >> = binary_part(data, offset, size)

    { decoded, offset + size }
  end
  defp decode_float(0, _, offset), do: { 0.0, offset }

  defp decode_map(map, size, data, offset) when 0 < size do
    { key, offset } = decode(data, offset)
    { val, offset } = decode(data, offset)

    decode_map(Map.put(map, String.to_atom(key), val), size - 1, data, offset)
  end
