Fix iteration issue with array ordering