try to be more threadsafe