improving tear down logic