Fixing an issue with array indexing on object arrays