update color change algorithm