add statement to check query by remote id conditioning