Fix logic in filter