adding exit condition.