Added frequency calculation