start of connection code