adding gray conversion