added new terminate procedure