fixes to when handling a connection that already exists and creating a new connection