control crazy processes

Hi,
maybe it is simple, but how to check for user processes, who consume the most cpu power ?
my goal is to control/quit processes who hang or consume too much cpu-power, for whatever reason they play crazy.

tell application "System Events"
	set win_apps to unix id of processes whose background only is false
	set count_win_apps to number of items in win_apps
	set user_nm to name of current user
end tell

set unixid to ""
repeat with a in win_apps
	set unixid to unixid & ("-pid " & a & space as text)
end repeat
set unixid to unixid as text

do shell script "top -l 1 -o cpu " & unixid & " -user " & user_nm & " | tail -" & count_win_apps

tried to code another version.
As said before, sometimes Apps hang and i find it easier to use a Script than to launch Activity monitor, sort things, quit thing and close Activity monitor again. Suggestions or improvements about the reliability of my Script?

property nr_apps : 10

on run
	set cpu_sorted to paragraphs of (do shell script "top -l 1 -o cpu -n " & nr_apps & " -ncols 3 | tail -" & nr_apps)
	set hang_apps to {}
	repeat with a in cpu_sorted
		set cpu_load to last word of a
		set cpu_load to my find_rep(cpu_load)
		
		if cpu_load > 25 then copy a to end of hang_apps
	end repeat
	
	if hang_apps is not {} then
		activate
		set ch to choose from list hang_apps with prompt "Quit App"
		if ch is false then return
		set ch to ch as text
		
		set get_pid to word 1 of ch
		#6,9,15
		#do shell script "kill -15 " & w1
		tell application "System Events" to quit (processes whose unix id is get_pid)
	else
		say "no blocking apps found" using "Alex"#"Keine blockierten Apps gefunden!" using "Anna"
	end if
end run

on find_rep(T)
	set tid to text item delimiters
	set text item delimiters to "."
	set T to text items of T
	set text item delimiters to ","
	set T to T as string
	set text item delimiters to tid
	return T
end find_rep