make code more efficient by only running histogram 1 once