Minor rewrite of changeColor to provide better performance