In theory thats correct however is not quite the hard problem to fix

A simple check to see if server is null meaning connection is not current.

if (!$server) { echo -a result }
else { perform old stuff from the script }


Code:
if $reality > $fiction { set %sanity Sane }
Else { echo -a *voices* }