Fix filtering query