modify ending condition