Method for creating a new Query object