the histogram part has been modified based on suggestions