added error handling for tcp client