fix multithread issue