error handling and send method