refactor bar chart