fix multi-threading problem