fixing the logic behind when to reset the color variable