Added some error checking of data before sending to the server