adding last bits of termination code