updated grayscale function