Added exception handling to send_data