fixed more indexing bugs