Fixed a thread-safe issue