fix bug with applying incorrect filter at the edges