added into-gray function