       group.lines.map (line) ->
         if line.context? # line is actually a group...
           console.log "TODO manage nested context"
-        else  
+        else
           line.context = {}
           line.context.people = group.context.people
         line

define ->
  Array::sum = (fn = (x) -> x) ->
    @reduce ((a, b) -> a + fn b), 0

  class Brain


      computing.totalSpentAmount = line.payers.sum (x) -> x.amount
      computing.totalFixedAmount = line.beneficiaries.sum (x) -> x.fixedAmount
      computing.totalOffset = line.beneficiaries.sum (x) -> x.offset
      computing.totalMultiply =line.beneficiaries.sum (x) -> x.multiply
      # save intermediate computation in line
      line.computing = computing
      # return line object
      line

    preprocessLine: (line) =>
      console.log "line", line
      # add beneficiaries from context if none is defined
      unless line.beneficiaries?
        line.beneficiaries = line.context.people.map (name) -> {name: name}
      # add remaining beneficiaries if option "group" is present
      if @getOption(line, "group")
        missingBeneficiaries = line.context.people.filter (personName) =>
          console.log "personName", personName
          not line.beneficiaries.hasElementMatching (ben) -> ben.name == personName
        console.log "missing", missingBeneficiaries
        line.beneficiaries.push {name: name} for name in missingBeneficiaries
      # compute fixed amount, offset and multiply
      line.beneficiaries = line.beneficiaries.map (ben) ->
        ben.fixedAmount = 0
