         switch data.toString()
           when 'OK'
             cb = @conn.messageCallbacks.shift()
-            cb null if cb?
+            cb? null
           when '_heartbeat_'
             @conn.write wire.nop()
 

      Enter: (err) ->
        # If there's a callback, pass it the error.
        cb = @conn.messageCallbacks.shift()
        cb err if cb?

        @conn.emit NSQDConnection.ERROR, err
        @goto 'CLOSED'

    CLOSED:
      Enter: ->
        # If there are callbacks, then let them error on the closed connection.
        err = new Error 'nsqd connection closed'
        for cb in @conn.messageCallbacks
          cb? err
        @conn.messageCallbacks = []

        @stop()
