fixed up script for latest code from customer.  this should be the finalized code