Added security check for the locality reproduction algorithm