fix multithreaded