script to identify all ip address outside the range

hi guys
Why doesn’t this script work?!
The way it works is to identify all ip address outside the range(192.168.8.0-192.168.15.255
identify the MAC, and remove it from the host plz help

:foreach h in=[/ip hotspot host find] do={
:global address [/ ip hotspot host get $h address];
:global mac [/ip hotspot host get $h mac-address];
:if (($address<$192.168.8.0)||($address>$192.168.15.255)) do={
ip hotspot host remove [find mac-address=$mac]
:log info "$mac Removed"
;
}}



{
:local startadd 192.168.8.0
:local endadd 192.168.15.255
:local a
:local mac
:foreach i in=[/ip hotspot host find ] do={
:set a [/ip hotspot host get number=$i address  
:set mac [/ip hotspot host get number=$i mac-address
 ]
:if (($a<$startadd)||($a>$endadd)) do={
ip hotspot host remove [find mac-address=$mac]
:log info "$mac removed from host"
}}}

Why all that mess?

Only one line suffice.

/ip hotspot host remove [find where !(address in 192.168.8.0/21)]
# or
/ip hotspot host remove [find where ( (address < 192.168.8.0) and (address > 192.168.15.255) )]

If you want logging simply do:

/ip hotspot host
:foreach item in=[find where !(address in 192.168.8.0/21)] do={
    :log info "Host $[get $item mac-address] removed because have IP $[get $item address]"
    remove $item
}

Thank you for your help.