wrap indexing in try