I don't think this will ever evaluate True when new_state == STATE_FAILED. Instead of "or", you should have a comma.