     for xValue, idx in [@data.x...]
       @data.x[idx] = xValue - @smallestX
 
-    # remove outliers and normalize
-    @removeOutliers(nsigma=8)
+    # normalize
+    @processLightcurve()
 
     # update min/max values
     @smallestX = Math.min @data.x...

      @ctx.textAlign = 'left'
      @ctx.fillText( @toDataYCoord((-yClick+@canvas.height)).toFixed(4), 15, yClick+5 ) # don't forget to flip y-axis values
      
  removeOutliers: (nsigma) ->
    mean = @mean(@data.y)
    std = @std(@data.y)
    x_new = []
    y_new = []
    for value, i in [@data.y...]
      if Math.sqrt( Math.pow( value - mean, 2 ) ) > nsigma * std
        # console.log 'removed outlier!'
        continue
      else
        x_new.push @data.x[i]
        y_new.push @data.y[i]

    # normalize
    yMax = Math.max y_new...
    yMin = Math.min y_new...

    mean = @mean(y_new)
    std = @std(y_new)

    # console.log 'MEAN: ', mean
    # console.log 'STD : ', std

    for y, i in [ y_new... ]
      y_new[i] = (y-1)/(std)
      y_new[i] = y/(mean)
     
    @data.x = x_new
    @data.y = y_new


  std: (data) ->
    mean = @mean(data)


class CanvasGraph

  DEBUG = false

  constructor: (@canvas, @data) ->
    @leftPadding = 60
