added initial code for establishing a connection