why does it die when it finds a duplicate?