code for the safe break - Search