code cleanup: move user defined pie chart creation to function, as it is (or will be) used at multiple places