Refactor -toArray using -collect and -first