changed connect/disconnect error handling