     @connection.write(packet.buffer)
 
   logPacket: (text, packet) ->
-    @debug((log) ->
-      log(text + ' packet')
-      
-      log(packet.headerToString('  '))
-      log('')
-      log(packet.dataToString('  '))
-      log('')
-    )
+    @debug(text + ' packet')
+    @debug(packet.headerToString('  '))
+    @debug('')
+    @debug(packet.dataToString('  '))
+    @debug('')
 
-  debug: (debugFunction) =>
+  debug: (text) ->
     if @listeners('debug').length > 0
-      debugFunction((text) =>
-        if !@closed
-          @emit('debug', text)
-      )
+      if !@closed
+        @emit('debug', text)
 
 module.exports = Connection

      @logPacket('Received', packet);

      preloginPayload = new PreloginPayload(packet.data())
      @debug((log) ->
        log(preloginPayload.toString('  '))
      )

      @packetBuffer = new Buffer(0)


    packet.last(true)
    
    @sendPacket(packet)
    @debug(preloginPayload.toString('  '))
    #@state = STATE.SENT_PRELOGIN

  sendPacket: (packet) =>
