fixed major bug with indexing on the main thread