initial code for auto-connect procedure