fix thread safe issue