Fix use of wrong index when checking for duplicates. Bug 31234526 Change-Id: Ia37d1b04a9054b8d90957057db857633e4b79569