Added fix for loss of connection