destructor added. fixed memory leaks by using weak_ptr