fixed and improved search for invalid ids and duplicate pnds