If you compute the histogram while generating the preview, maybe that will simplify the code. But it may mean that the worker is not ncecessary.