check last iteration around the raise statement