diff --git a/servers/servertcp_handler.js b/servers/servertcp_handler.js
index <HASH>..<HASH> 100644
--- a/servers/servertcp_handler.js
+++ b/servers/servertcp_handler.js
@@ -123,8 +123,8 @@ function _handleReadCoilsOrInputDiscretes(requestBuffer, vector, unitID, callbac
                 msg: "Invalid length"
             });
 
-        var cb = buildCb(i);
         var i = 0;
+        var cb = buildCb(i);
         var promiseOrValue = null;
 
         if (isGetCoil && vector.getCoil.length === 3) {
Fix var beeing used before assignment (#<I>)