break out runQuery into an internal query