improve indexing script