Application runner and iTunes player

This is a little script I have been woring on that allows you to run any application by typing in it’s name. Also, if you place a space infront of the text you type in, it will play that song in iTunes. The only thing is remembering to press the quit button when shutting down. Otherwise it’ll stop shutdown. Any fixes?

property target : ""
tell application "Finder" to activate
repeat
	try
		tell application "System Events" to set FRontApp to name of (first application process whose frontmost is true)
		if FRontApp is "Runner" then
			set ldtarg to target
			activate
			set target2 to (display dialog "Insert program name:" default answer target buttons {"Quit", "NVM", "OK"} default button "OK")
			if the button returned of target2 is "OK" then
				set target to the text returned of target2
				if the first character of target is " " then
					set songname to ""
					repeat with i from 2 to the number of characters in target
						set songname to songname & character i of target
					end repeat
					tell application "iTunes" to tell playlist "Music" to play (first track whose name is songname)
					set target to ldtarg
				else
					tell application target
						run
						delay 1
						activate
					end tell
					tell application "Finder" to activate
				end if
			else if the button returned of target2 is "Quit" then
				exit repeat
			else
				tell application "Finder" to activate
			end if
		end if
	on error e
		
	end try
end repeat