code: function(index) {
                          tsdb.saveAnnotation(annotations[index], function(data) {
                              annotations[index] = data;
                              receivedResponses++;
                              if (receivedResponses == expectedResponses) {
                                  if (errorsReceived.length > 0) {
                                      errorFn(annotations, errorsReceived);
                                  }
                                  else {
                                      successFn(annotations);
                                  }
                              }
                          }, function(error) {
                              receivedResponses++;
                              errorsReceived.push(error);
                              if (receivedResponses == expectedResponses) {
                                  errorFn(annotations, errorsReceived);
                              }
                          })
                      }
docs: nasty inner function to get around closure issues