Cleaning up the TF-IDF logic