break up inverted index function into smaller units