Using conditional and while loop objects to control the execution order