Fix bug where existence check was looking at the wrong table.