Updated the frequency logic