Fixed the multi-threading