#2 fixed undefined clauses in query