added downscaling in c