   defp socket_close(pid, {state, socket}) do
     case state.channels_inverse do
       %{^pid => {topic, join_ref}} ->
-        {^pid, monitor_ref} = Map.fetch!(state.channels, topic)
+        {^pid, monitor_ref, _status} = Map.fetch!(state.channels, topic)
         state = delete_channel(state, pid, topic, monitor_ref)
         {:push, encode_close(socket, topic, join_ref), {state, socket}}
 

        {:ok, {state, socket}}
    end
  end
end

    handle_in(nil, message, new_state, new_socket)
  end

  defp handle_in({pid, _ref, _status}, message, state, socket) do
    send(pid, message)
    {:ok, {maybe_put_status(state, pid, message), socket}}
  end

  defp handle_in(nil, %{event: "phx_leave", ref: ref, topic: topic, join_ref: join_ref}, state, socket) do
