improved code for HA-setups