add the frequency function