Added wraparound for hue detection