fix pathQuery issue

clone ids-array, add some checks
Merge pull request #191 from dmapper/master

fix pathQuery issue