How to exit a nested if statement

Use a flag (boolean variable) to indicate whether the button has been pushed.