Sorry, a small oversight (remember I cannot run it!).
The three element blue array is accidentally set to autoindex. Remove autoindexing and you should be OK.
(arrow in the attached corrected example shows where the mistake was).
EXPLANATION: A FOR loop only runs as many times as the smallest autoindexing array. Dont set the loop count manually, it will now run according to the size of the 2D boolean array.