modified the lattice histogramming function