added automatic update of histogram