integrated inverted index code into part c