Extracted connect logic into separate method