 
 requests = []
 for d, i in dates
-  do (d) ->
+  do (d, i) ->
     requests.push(processCards(getCards(d[0], d[1])).then (val) ->
         new Promise (resolve, reject) ->
           Promise.all(val).then((success) ->
             console.log "[=] (" + i + ") " + d[0] + " - " + d[1] + ":\t" + success.length + " cards"
-            resolve()
+            success.sort sortOldest
+            resolve(success[0])
           , (fail) ->
             reject(fail)
           )

            if action.data.list.id == rightnow
              finished = true
            closed_date = action.date
          catch error
            console.error "Could not access data, ", error
            console.error (util.inspect card, {depth: null, color: true})

        # Insert into database
        q = client.query
          text: "SELECT trello.insert_card($1, $2, $3, $4, $5, $6)"
          name: 'cardinsert'
          values: [card.id, card.name, card.closed, finished, creation_date, closed_date]
        , (err, result) ->
          if err
            # Close connection
            done(client)
            error err
            return
          # Release the database connection
          done()
          success()

# Recurse for optional depth iterations
processCards = (cards) ->

      host: 'localhost'
      ssl: false,
      (err, client, done) ->
        dates = []
        # Grab the creation date
        creation_date = null
        creation_date = action.date for action in card.actions when action.type == 'createCard' || action.type == 'convertToCardFromCheckItem' || action.type == 'copyCard' || action.type == 'moveCardToBoard'
        dates.push new Date(creation_date)

        # If the card is closed, find the date and whether it was in 'rightnow'
        closed_date = null
