Fixed issue: Added missed connection check