Added multi-threading