fixing query inclusion and constraints