Slight generalization of distribution script