hack to make threadsafe