Fixed hist2d function