Added exit condition