Some drivers need a longer wait, So i would try to place a PAUSE 30 or PAUSE 60 after the ELSE.
I notice that its not consistent on drivers, so drivers like VARA dont need those, but if you use WinRPR, they dont seem to fully release the port for around 30 seconds.
I would also recommend you put IDLETIME 60 in there before each ATTACH. This is a failsafe if the modem gets LOCKED and does nothing, it will break out of that cycle in 1 minute.
Maybe John has better suggestions, but these are general ones I employ across a wide range of different modem types so I think they'd be a good practice to try.
73