Fixed bugs in the filter