fix pathQuery issue

clone ids-array, add some checks