Fix pie chart logic