some improvements to the frequency analysis