Added threadsafe option