adding exit conditions