remove unnecessary iterator_to_array which can cause memory exhaustion