diff --git a/src/Node.cpp b/src/Node.cpp
index bc36d21f89fbaae123bab7aca16a27f466bf6a05..387b313f949864c37f17b6b755addc8f5fdb7a1e 100644
--- a/src/Node.cpp
+++ b/src/Node.cpp
@@ -1201,8 +1201,7 @@ void Node::handleTcpMessage()
 					vector<string> unsentDir;
 					int idx = 0, range = entireDir.size();
 					while (idx < range){
-						if (sentLocally.count(entireDir[idx])) continue;
-						else {
+						if(sentLocally.count(entireDir[idx]) == 0) {
 							unsentDir.push_back(entireDir[idx]);
 							unsentDir.push_back(entireDir[idx+1]);
 						}
@@ -1211,10 +1210,11 @@ void Node::handleTcpMessage()
 					int filesHere = unsentDir.size() / 2;
 					Messages outMsg(STARTMERGE, nodeInformation.ip + "::" + to_string(filesHere));
 					this->tcpServent->sendMessage(leaderIP, TCPPORT, outMsg.toString());
+					if (filesHere == 0) break;
 					string toProcess = "";
 					int index = 0, dirRange = unsentDir.size(), partition = 10;
 					while (index < dirRange){
-						while ((index < range) && (partition > 0)){
+						while ((index < dirRange) && (partition > 0)){
 							if (toProcess.size()) toProcess += ",";
 							toProcess += (unsentDir[index] + "," + unsentDir[index+1]);
 							index += 2;
@@ -1230,6 +1230,8 @@ void Node::handleTcpMessage()
 				}
 				else{
 					filesAtWorker[inMsg[0]] = stoi(inMsg[1]);
+					Messages alreadyDone(MERGECOMPLETE, inMsg[0] + "::");
+					if (filesAtWorker[inMsg[0]] == 0) tcpServent->regMessages.push(alreadyDone.toString());
 				}
 				break;
 			}