inverted index main function