Try replacing your line 107 with the following. IF PCOR==RGB((255 DIV 8)*8,(70 DIV 8)*8,(70 DIV 8)*8) THEN ...