Updated histogram_fixing.py to fix a few logical errors