utils/post_freq: make the code more robust