Histogram function works properly