Moved code out of array helper functions