 
             p.exit().remove()
 
-        for dataset, index in @options.datasets
-            do (dataset, index) ->
-                drawDataset(dataset, index)
+        for dataset in @options.datasets
+            do (dataset) => @drawDataset(dataset)
 
         redraw = =>
             # update brush

            .attr('height', @options.height)
            .attr('transform', "translate(0, #{options.height - 18})")

        drawDataset = (dataset, index) =>
            @root.select('g.datasets')
                .append('g')
                    .attr('class', 'dataset')
                    .attr('id', "dataset-#{dataset.id}")
            el = @root.select("g.datasets #dataset-#{dataset.id}")

            @data[dataset.id] = {
                index: index,
                color: dataset.color,
                callback: dataset.data,
                points: [],


    # TODO
    addDataset: (dataset) ->
        @drawDataset(dataset)
        true

    # TODO
