rewrote indexing script