The expression of genes in an organism can be influenced by the environment, adding the external world in which the organism is or where it develops, as well as the organism's internal world, which includes such factors as its hormones and metabolism.
Well oxygen has 6 electrons in its outer shell and mg has 2. Oxygen need two to complete it's outer shell and mg needs to lose 2 to gain a complete out we shell.