add failover code