edited grayscale function