supporting multithreads
stable multithread version