Automount Script + VPN + Multi Volume

Looking for anyways to make this better. Plus I’ve seen people looking for something like this.

All info has been changed for protection

#Airport Login Info
property server : "1.1.1.1"
property user : "username"
property pass : "password"
#Drive Info
set serverVolume to {"volume1", "volume2"}
set IFafpSETto1 to {1, 1} #if smb set to 0
property totalVolume : 2 #looking for a way to remove this
#Gateway info / VPN if you dont have a vpn... set vpn to off and dont worry about other settings. 
property vpn : "on" #on or off
property vpnip : "1.1.1.1" #changed for protection

repeat
	set testIP to chkUP("http://www.apple.com") or chkUP("http://www.google.com")
	if testIP then
		repeat
			try
				set theGateway to do shell script "route get default | grep gateway | tr -d \"gateway:  \""
				set theVPN to do shell script "netstat -rn | grep UGScI | tr -s \" \" | cut -d\" \" -f2"
				if theGateway = server or theVPN = vpnip then
					repeat with serverCount from 1 to totalVolume
						if (item serverCount of serverVolume) is not in (do shell script "/bin/ls /Volumes") then
							if 1 = (item serverCount of IFafpSETto1) then
								set flag to mountAFP(user, pass, server, (item serverCount of serverVolume))
							else if 0 = (item serverCount of IFafpSETto1) then
								set flag to mountSMB(user, pass, server, (item serverCount of serverVolume))
							end if
						else
							set flag to true
						end if
						if flag then
						end if
					end repeat
					exit repeat
				else if theGateway ≠ server or theVPN ≠ vpnip or vpn = "off" then
					repeat
						if vpn = "on" then
							set decisionVPN to display dialog "Not Connected to Home Network" & return & "Connect to VPN?" buttons {"Yes", "No"} default button "Yes"
							log decisionVPN
							set decisionVPN to button returned of decisionVPN
							if decisionVPN is "No" then
								quit
							else if decisionVPN is "Yes" then
								tell application "System Events"
									tell current location of network preferences
										set VPNservice to service "VPN (PPTP)" -- name of the VPN service
										set isConnected to connected of current configuration of VPNservice
										connect VPNservice
										delay 4
										exit repeat
									end tell
								end tell
							end if
						else if vpn = "off" then
							internetEND()
						end if
					end repeat
				end if
			end try
		end repeat
		exit repeat
	else
		internetEND()
	end if
end repeat

to chkUP(theURL)
	return (count (get ((theURL as URL)'s host & {dotted decimal form:""})'s dotted decimal form)) > 0
end chkUP

on internetEND()
	set internetDecision to display dialog "Unable to Detect Internet" & return & "Connect to Internet" buttons {"Yes", "No"} default button "Yes"
	log internetDecision
	set internetDecision to button returned of internetDecision
	if internetDecision is "No" then
		quit
	else if internetDecision is "Yes" then
		if vpn = "off" then
			display dialog "Not on home network"
			quit
		end if
	end if
end internetEND


on mountAFP(user_name, pass_word, thehost, theVolume)
	set theAddress to quoted form of ("afp://" & user_name & ":" & pass_word & "@" & thehost & "/" & theVolume)
	set mountpoint to quoted form of ("/Volumes/" & theVolume)
	try
		do shell script "/bin/mkdir " & mountpoint & "; /sbin/mount_afp " & theAddress & space & mountpoint
		return true
	on error
		do shell script "/bin/rm -r " & mountpoint
		return false
	end try
end mountAFP

on mountSMB(user_name, pass_word, thehost, theVolume)
	set theAddress to quoted form of ("smb://" & user_name & ":" & pass_word & "@" & thehost & "/" & theVolume)
	set mountpoint to quoted form of ("/Volumes/" & theVolume)
	try
		do shell script "/bin/mkdir " & mountpoint & "; /sbin/mount_smbfs " & theAddress & space & mountpoint
		return true
	on error
		do shell script "/bin/rm -r " & mountpoint
		return false
	end try
end mountSMB