       }
       orgs
 
-    @paidFor = @komp =>
-      @payer() and (@payer() isnt VM.current_user().login)
-
-    @selfPayer = @komp =>
-      @payer() and (@payer() is VM.current_user().login)
-
-    @notPaid = @komp =>
-      not @payer()?
-
-    @savedCardNumber = @komp =>
-      return "" unless @cardInfo()
-      "************" + @cardInfo().last4
-
-
-    # use computed observable because knockout select boxes make it hard to do otherwise
+    @organizations = @komp =>
+      (k for k,v of @teamMembers())
+
     @selectOrganization = @komp
+      # use computed observable because knockout select boxes make it hard to do otherwise
       write: (value) =>
         @selectedOrganization(value)
         if value

class Billing extends Obj
  observables: =>
    teamMembers: {} # github data; map of org->[users]
    stripeToken: null
    availablePlans: [] # the list of plans that a user can choose
    selectedOrganization: null
    selectedPlan: null
    collaborators: []
    cardInfo: null
    payer: null
    plan: null
    oldTotal: 0

  constructor: ->
    super
    @plans = @komp =>
      ap = for k,v of @availablePlans()
        v.id = k

        b.price - a.price # most expensive first
      ap

    @selectedPlan = @komp =>
      if @chosenPlan()?
        @chosenPlan()
      else if @existingPlanName()? and @availablePlans()?
        @availablePlans()[@existingPlanName()]


    @userMatrix = @komp =>
      users = {}
      for c in @collaborators()
        users[c.login] = c.plan().id if c.plan()?
      users

    @total = @komp =>
      total = 0
      for c in @collaborators()
        total += c.plan().price if c.plan()?
      total / 100

    @paidFor = @komp =>
      @payer() and (@payer() isnt VM.current_user().login)

    @selfPayer = @komp =>
      @payer() and (@payer() is VM.current_user().login)

    @notPaid = @komp =>
      not @payer()?

    @savedCardNumber = @komp =>
      return "" unless @cardInfo()
      "************" + @cardInfo().last4




    @organizationMatrix = @komp =>
      orgs = {} # TODO: merge with existing plans
