add advancequery function