Add ending condition