     request.end()
 
   subscribe: (subdomain, flow) ->
-    @flows.push(
-      subdomain: subdomain
-      name: flow
-    )
-    return if @cookies.length == 0
+    if @cookies.length == 0
+      @on "login", =>
+        @subscribe subdomain, flow
+      return
+
+    if @flows.filter((f) -> f.subdomain == subdomain && f.name == flow).length == 0
+      @flows.push(
+        subdomain: subdomain
+        name: flow
+      )
 
     options =
       host: subdomain + host

    @cookies = []
    @flows = []
    @users = []
    @login(() =>
      @flows.forEach((flow) =>
        @subscribe(flow.subdomain, flow.name)
      )
    )

  start: () ->
    @socket = new FlowdockSocket(@cookies, @clientId)
    @socket.on "message", (message) =>
      @emit("message", message)

  login: (callback) ->
    post_data = querystring.stringify(
      "user_session[email]": @email
      "user_session[password]": @password

      )
      res.on "end", () =>
        @emit "login"

    req.write(post_data)
    req.end()
