added freqvals and some minor modification in the code to include the freqvals