Code is not syncing to Pavlovia

Description of the problem: I am using the following code on Psychopy to get mouse clicks on each square of a grid. For right click the square changes to one colour and for left click the square changes into another colour.
This is the code in “Each frame” section. There is nothing else in the other sections of the code component.

squares = [g11, g12, g13, g14, g15, g21, g22, g23, g24, g25, g31, g32, g33, g34, g35, g41, g42, g43, g44, g45, g51, g52, g53, g54, g55];
buttons = mouse.getPressed();
for (var square, _pj_c = 0, _pj_a = squares, _pj_b = _pj_a.length; (_pj_c < _pj_b); _pj_c += 1) {
    square = _pj_a[_pj_c];
    if (mouse.isPressedIn(square)) {
        pressed_square = square;
        if (mouse.isPressedIn(pressed_square, {"buttons": [0]})) {
            pressed_square.fillColor = "cyan";
        } else {
            if (mouse.isPressedIn(pressed_square, {"buttons": [2]})) {
                pressed_square.fillColor = "crimson";

The code component is running fine in builder but shows the following error in Pavlovia
ReferenceError: pressed_square is not defined


Put pressed_square = ''; in Begin Routine