convert countsToPieData into static method