updating code so that IndexHits objects are closed after being used