fixed multithreading bug