add condition if a query failed