Changed code to calculate IDF only once, to decrease runtime