private void handleProcessClear(){
        for(int i:processesMap.keySet()){
            if((processesMap.get(i).getStatus() == Status.FINISHED.toString()) ||
                    (processesMap.get(i).getStatus() == Status.FAILED.toString())){
                Message msg = new Message(Message.msgType.COMMAND);
                msg.setCommandId(CommandType.REMOVEPROC);
                msg.setProcessId(i);
                int workerId = processesMap.get(i).getWorkerId();
                try{
                    
                processServerMap.get(workerId).sendToWorker(msg);
                }catch(IOException e){
                    System.out.println("remove Command sent failed, remove worker "+workerId);
                    removeNode(workerId);
                }
                processesMap.remove(i);
            }
        }
    }