You could just use map here and not have to use the intermediary array for storage.