updated query generation for text