better algorithm for downscaling