multi_thread version, little modification