updated functions for connection and disconnection