improved error handling for the send command