reconnect() function for manual reconnection