how does the nervous system working together with endocrine system to maintain homoestasis?