correct logical error in autoconnect procedure. stop if ports[i] was null the first time