function(allstates, event, ...)
    local unitID = ...
    local group = aura_env.group
    local hplimit = aura_env.hplimit
    
    for i = 1, GetNumGroupMembers() do
        if unitID == group..i then
            local curHP = UnitHealth(group..i)
            local maxHP = UnitHealthMax(group..i)
            local percent = (curHP / maxHP) * 100
            
            allstates[unitID] = allstates[unitID] or {}
            local state = allstates[unitID]
            
            if percent < hplimit and state.show == true then
                return
            end
            
            state.show = false
            
            if percent < hplimit then
                state.show = true
                state.changed = true
                state.name = group..i
            end
        end
    end
    return true
end

aura_env.hplimit = 60 --health percentage threshold, change to whatever number you want (1-100)

-----------------------------------------
--DONT CHANGE ANYTHING BELLOW THIS LINE--
-----------------------------------------

aura_env.me = UnitGUID("player")
aura_env.group = "party"
if IsInGroup() and not IsInRaid() then
    aura_env.group = "party"
elseif IsInRaid() then
    aura_env.group = "raid"
end

aura_env.frameTable = {}

-- Send this function a group/raid member's unitID or GUID and it will return their raid frame.
function aura_env.GetFrame(target)
    if not UnitExists(target) then
        if type(target) == "string" and target:find("Player") then
            target = select(6, GetPlayerInfoByGUID(target))
        else
            return
        end
    end
    --ShadowUF
    if IsAddOnLoaded("ShadowedUnitFrames") then
        if ShadowUF.enabledUnits.raid then
            for _, frame in pairs(ShadowUF.Units.unitFrames) do
                if frame.unitType == "raid" and frame:IsVisible() and frame.unit and UnitIsUnit(frame.unit, target)
                    then
                    return frame
                end
            end
        end
    end
    -- CompactRaid
    if IsAddOnLoaded("CompactRaid") then
        return CompactRaid:FindUnitFrame(target)
    end
    -- Healbot
    if IsAddOnLoaded("HealBot") then
        for _, frame in pairs(HealBot_Unit_Button) do
            if UnitIsUnit(frame.unit, target) then
                return frame
            end
        end
    end
    -- Vuhdo
    if IsAddOnLoaded("VuhDo") and VUHDO_CONFIG["SHOW_PANELS"] then
        for _, v in pairs(VUHDO_UNIT_BUTTONS) do
            if v[1].raidid and UnitIsUnit(v[1].raidid, target) then
                return v[1]
            end
        end
    end
    if IsAddOnLoaded("Grid") then
        for _, frame in pairs(Grid.modules.GridFrame.registeredFrames) do
            if frame:IsVisible() then
                if frame.unit and UnitIsUnit(frame.unit, target) then
                    return frame
                end
            end
        end
    end
    --Grid2
    if IsAddOnLoaded("Grid2") then
        for _, frame in pairs(Grid2Frame.registeredFrames) do
            if frame:IsVisible() then
                if frame.unit and UnitIsUnit(frame.unit, target) then
                    return frame
                end
            end
        end
    end
    -- ElvUI
    if ElvUF then
        for _, frame in pairs(ElvUF.objects) do
            if (frame.unitframeType == "raid"
                or frame.unitframeType == "party"
                or frame.unitframeType == "raid40"
            )
            and frame:IsVisible() and frame.unit and UnitIsUnit(frame.unit, target)
            then
            return frame
        end
    end
end
-- bdGrid
if IsAddOnLoaded("bdGrid") then
    for _, frame in pairs(oUF_bdGridRaid) do
        if UnitIsUnit(frame.unit, target) then
            return frame
        end
    end
end
--Lastly, default frames
if CompactRaidFrameContainer.groupMode == "flush" then
    for _, frame in pairs(CompactRaidFrameContainer.flowFrames) do
        if frame.unit and frame:IsVisible() and UnitIsUnit(frame.unit, target) then
            return frame
        end
    end
else
    for i = 1, 8 do
        for j = 1, 5 do
            local frame = _G["CompactRaidGroup"..i.."Member"..j]
            if frame:IsVisible() and frame.unit and UnitIsUnit(frame.unit, target)
                then
                return frame
            end
        end
    end
end
-- debug - uncomment below if you're seeing issues
--print("GlowOnDemand (WA) - No frame found. Target sent: ".. target)
end

local frame = aura_env.GetFrame(aura_env.statee.name)
if frame then
    local LBG = LibStub("LibButtonGlow-1.0")
    table.insert(aura_env.frameTable, frame)
    LBG.ShowOverlayGlow(frame)
end

local frame = aura_env.GetFrame(aura_env.statee.name)
local LBG = LibStub("LibButtonGlow-1.0")
for i, v in ipairs(aura_env.frameTable) do
    if v == frame then
        table.remove(aura_env.frameTable, i)
        break
    end
end
LBG.HideOverlayGlow(frame)

function(t)
    if not t[1] then
        if #aura_env.frameTable > 0 then
            for _, v in ipairs(aura_env.frameTable) do
                local LBG = LibStub("LibButtonGlow-1.0")
                LBG.HideOverlayGlow(v)
            end
        end
        aura_env.frameTable = {}
    end
    return t[1]
end
