Add frequency function