improvements on the distribute script