modify the condition to handle error