added error message to function setState