fixed multi-threaded issue