make threadsafe and optionally not