fix script to clean up &, as well as split array into smaller arrays