refine multi-threading