cleaned up the fail_closed code