/** Iterate and deploy verticles */
  private void deployVerticle(final Message<JsonObject> event) {

    // iterate over all candidates to be deployed
    Set<String> candidates = this.workingCopy.fieldNames();

    // detach from underlying json
    Map<String, JsonObject> initiants = new HashMap<>();
    candidates.forEach(
        id -> {
          JsonObject info = this.workingCopy.getJsonObject(id);
          JsonArray dependsOn = info.getJsonArray("dependsOn");
          if (dependsOn != null && deployed.getList().containsAll(dependsOn.getList())
              || dependsOn == null
              || dependsOn.isEmpty()) {
            initiants.put(id, info);
          }
        });

    // remove the initiants
    initiants.keySet().forEach(id -> this.workingCopy.remove(id));

    // setup latch for the reply
    CountDownLatch latch = new CountDownLatch(initiants.size());
    if (initiants.isEmpty()) {
      event.reply(Boolean.TRUE);
      return;
    }

    // run over all dependencies
    initiants.forEach(
        (id, info) -> {

          // get the name of the verticle
          String name = info.getString("name");
          final JsonObject localConfig = new JsonObject();
          localConfig.mergeIn(globalConfig);
          localConfig.mergeIn(info.getJsonObject("config", new JsonObject()));

          Handler<AsyncResult<String>> handler =
              innerEvent -> {
                if (innerEvent.succeeded()) {
                  // add service to deployed-list
                  deployed.add(id);

                  // re-emit
                  vertx
                      .eventBus()
                      .send(
                          LOOPBACK,
                          workingCopy,
                          (AsyncResult<Message<Boolean>> recursiveReply) -> {
                            // always decrease latch
                            latch.countDown();

                            if (recursiveReply.succeeded() && recursiveReply.result().body()) {
                              if (latch.getCount() == 0) {
                                event.reply(recursiveReply.result().body() & Boolean.TRUE);
                              }
                            } else {
                              event.fail(500, this.getFailure(id, recursiveReply));
                            }
                          });

                } else {
                  event.fail(500, id + " >> " + innerEvent.cause().getMessage());
                }
              };

          LOG.log(Level.INFO, "Deploying: ''{0}''", new Object[] {id});
          DeploymentOptions deploymentOptions = new DeploymentOptions(info);
          vertx.deployVerticle(name, deploymentOptions.setConfig(localConfig), handler);
        });
  }