improved distribution script