updated query structure