begin implementation of histogram function