Make threadsafe