Extracted connection logic