trying to improve chat reconnection code