what system senses changes in the internal and external environment so that the body can adapt to the changes.