moved end scripts into the body