added comments to script and cleaned up