fixed seg fault due to double delete in tear down