the correct implementation of barchart