Add calculation for average frequency. Shall be tested.