updated connection code