fixed an indexing bug