     sub = null
 
     (interval) ->
-      sub?.dispose?()
+      sub?.dispose()
       sub = atom.workspace.observeTextEditors (editor) =>
         setTimeout =>
           editorPresenter = atom.views.getView(editor).component.presenter
           editorPresenter.stopBlinkingCursors true
           if interval > 0
-            @applySecondaryColor()
+            @applySecondaryColor @getConfig 'secondaryColor'
             editorPresenter.cursorBlinkPeriod = interval
           else
-            @applySecondaryColor()
+            @applyPrimaryColor @getConfig 'primaryColor'
             editorPresenter.cursorBlinkPeriod = -1 + Math.pow 2, 31
           editorPresenter.startBlinkingCursors()
         , 0

  applySecondaryColor: (color) =>
    if 0 is @getConfig 'blinkInterval'
      color = @getConfig 'primaryColor'
    else
      color ?= @getConfig 'secondaryColor'
    @updateStylesheet secondarySelector, 'background-color', color.toRGBAString()
    @updateStylesheet secondarySelector, 'border-color', color.toRGBAString()

  applySecondaryColorAlpha: (alpha) =>
    secondaryColor = @getConfig 'secondaryColor'

    atom.config.set "block-cursor.#{key}", value

  observeConfigs: (obj) ->
    for own key, cb of obj
      @subs.add atom.config.observe "block-cursor.#{key}", cb

module.exports = new BlockCursor()
