r indexing gotcha fix