separated the function that calculates proportion of occurences