Iterate Window in Specified Application

I get the error code: System Events got an error: Can't get application of "Application Name" during this line

repeat with currentWindow in every window of application foregroundApp

of this code

on run
	tell application "System Events"
		set foregroundApps to displayed name of (every process whose background only is false) as list
		repeat with foregroundApp in foregroundApps
			set appName to foregroundApp as text
			if exists (window 1 of process appName) then
				repeat with currentWindow in every window of application foregroundApp
				end repeat
			end if
		end repeat
	end tell
end run

I'm guessing I'm missing something like

set x to foregroundApp as y
repeat with currentWindow in every window of application x

How do I get the windows of the application foreground app?

Iterate Window in Specified Application
 
 
Q