fix frequency calculation bug