finish building up query