refactored makeIndexedArray