Modifications made by Kevin G 

added some functionality and comments to improve overall functionality of the script.