FIX wrong substition in queries