error checking when sending data