major update - cleaned up the script