implement connect function