add function to calculate frequency