added back next query logic