fixing an indexing bug