bug fix for multithread