improved threadsafe publishing