add buildQuery method