Changing line color on mouse click

Ok so I have this kind of working based on this example . The cards are changing colour on click, but the next set of cards is retaining the colour from the previous trial

As such, I think that I need something on the end Routine tab to clear the last trial selection.

for thisPolygon in polygons:
    if mouse.isPressedIn(thisPolygon):
        thisClickTime = clickClock.getTime()
        if (thisClickTime - lastClickTime) > bufferTime:
            if thisPolygon.fillColor =='red':
                thisPolygon.fillColor = 'white'
            else:
                thisPolygon.fillColor = 'red'
        lastClickTime = thisClickTime

Obviously I am certain this will break on upload to Pavlovia too. :face_with_raised_eyebrow: