update code for query