finished refactoring the pie chart code