updated tf-idf to be more efficient