optimized "weighted interpolation function" again