added connection check