fix error out when calculating idf