fix pie chart logic