performance: better to index than modify the array