Updated histogram code to be more DRY