work on adding terminate function

still in progress