split code into functions, added silence barchart