fixed the NaN error, and the histogram losing color error