fixing logic in the filter