added smoothing algorithm described in task 3.2