fixing the simplification in queries