Improved the connection and disconnection