Move all 'connect' logic into a private method