improved logic of color-getter function