Add proper handling of errors in successful connections