added the code for basic port reconnect