added a nest function for arrays