use Query.gensql method so it's more modular