make preview function threadsafe again