I think we can check these conditions in "while" loop