Fix bug where criteria does not returned expected IDs.