Bugfix. Was comparing to vertices[i] rather than rectangles[i].