updated query helper