I don’t have time to write the code, but could you try getting the indexes of the different types, appending to a list and then adding and dividing by the number of items in the list?