Optimize frequencyTable and update checkFrequency3