updated connection routine