Fixed the frequency calculation