Added connection check