added code for populating query words for each tree