Replace depricated toArray with collect