Switch between upstreams if no internet is detected

Below if my upstream overview. I want to keep default upstream to 172.16.0.65 but incase no internet is detected i want to route all my traffic to 192.168.31.1 until issue is resolved.

Below sharing my routine policy.
image

I have put static route 0.0.0.0/0 to 192.168.31.1 with metric less than 172.16.0.65 but still my traffic isnt being routed through 192.168.31.1 but i can ping 192.168.31.1

tried the mwan3 package ?

Still after configuring mwan its not still working ? If i enable lan then it works but when lan disabled its not working

Interface status:
 interface lan is offline 00h:00m:00s, uptime 00h:30m:26s and tracking is active
 interface wwan2 is online 00h:09m:17s, uptime 00h:10m:57s and tracking is active

Current ipv4 policies:
wwan2lan:
 wwan2 (100%)

Current ipv6 policies:
wwan2lan:
 unreachable

Directly connected ipv4 networks:
172.16.0.66
192.168.31.137
127.0.0.0/8
127.255.255.255
224.0.0.0/3
127.0.0.1
192.168.31.0/24
172.16.0.127
172.16.0.64/26
192.168.31.255

Directly connected ipv6 networks:
fe80::/64

Active ipv4 user rules:
    0     0 S https  tcp  --  *      *       0.0.0.0/0            0.0.0.0/0            multiport dports 443 
   93  4638 - wwan2lan  all  --  *      *       0.0.0.0/0            0.0.0.0/0            

Active ipv6 user rules:
    0     0 S https  tcp      *      *       ::/0                 ::/0                 multiport dports 443 
  178 37381 - wwan2lan  all      *      *       ::/0                 ::/0                 
root@OpenWrt_66:~# traceroute 1.1.1.1                                                                                                               traceroute to 1.1.1.1 (1.1.1.1), 30 hops max, 46 byte packets                                                                                        1  *  *  *                                                                                                                                          2  *  *  *                                                                                                                                          3  *  *  *                                                                                                                                          4  *^C    
Running 'ping -c 5 -W 1 1.1.1.1' with DEVICE=phy0-sta0 SRCIP=192.168.31.137 FWMARK=0x3f00 FAMILY=ipv4
PING 1.1.1.1 (1.1.1.1): 56 data bytes
64 bytes from 1.1.1.1: seq=0 ttl=56 time=56.822 ms
64 bytes from 1.1.1.1: seq=2 ttl=56 time=154.012 ms
64 bytes from 1.1.1.1: seq=3 ttl=56 time=58.735 ms
64 bytes from 1.1.1.1: seq=4 ttl=56 time=61.081 ms```