moved connect logic to new method