   def connect(opts) do
     host = Keyword.fetch!(opts, :host) |> to_char_list()
     port = Keyword.get(opts, :port, 9042)
-    case :gen_tcp.connect(host, port, @default_sock_opts, @default_timeout) do
-      {:ok, sock} ->
-        {:ok, options} = Utils.request_options(sock)
-        :ok = Utils.startup_connection(sock, options)
-        {:ok, %{sock: sock}}
-      {:error, reason} ->
-        {:error, Error.exception(action: "connect", reason: reason)}
-    end
+
+    with {:ok, sock} <- connect(host, port),
+         {:ok, options} <- Utils.request_options(sock),
+         :ok <- Utils.startup_connection(sock, options),
+         do: {:ok, %{sock: sock}}
   end
 
   def checkout(state) do

  def disconnect(_exception, %{sock: sock}) do
    :ok = :gen_tcp.close(sock)
  end
end

      {:ok, frame, state}
    else
      {:error, reason} ->
        {:disconnect, Error.exception(action: "execute", reason: reason), state}
    end
  end

