Chloroplasts originally evolved from photosynthetic bacteria by primary endosymbiosis, in which a bacterium or other prokaryote is engulfed by a eukaryotic host. The chloroplasts of red and green algae have subsequently come to reside within other, previously non-photosynthetic eukaryotes by secondary endosymbiosis. Such events have contributed to the global diversity of photosynthetic organisms that play a crucial role in regulating and maintaining the global carbon cycle. In most organisms that acquired photosynthesis by this mechanism, the nucleus from the ingested algal cell has disappeared, but in some cases it persists as a residual organelle known as a nucleomorph. Such organisms have four distinct genomes.