added code for connecting and disconnecting peers