change hue calculation for demos 3 and 4

prevent exceptions for Demos 3 and 4