"sudocode" for smoothing