edit generatequery return & add download fn