Made idf calculation faster

Implemented using list comprehension