updated build_body function