added some kind of error handling for when server returns an error