Step by step execution of an if statement

Hi everyone,

I have a question on the order of if statement consequences.
In my code I end my routine after one image has been selected for each of 3 categories.
Once an image is clicked I remove a frame around it as feedback for selection. After selection the variable select becomes 1. If all categories (A,B,C) are one the routine ends. The code works BUT…

Once the last image is clicked the frame is not removed anymore. I believe because the “select C=1” component is excluded before the "category_C.setAutoDraw(False) " component. How can I ensure they are excluded in the right order?

if mouse.isPressedIn(C)and(selectC==0):
decisiontimeC = Decision_phaseClock.getTime()

#same for A and B

#End routine after only one item per category is selected
if (selectA>0) and (selectB>0) and (selectC>0):
continueRoutine = False