fix thread safe problem